包装函数以返回其他类型

时间:2020-09-13 17:11:31

标签: c++ wrapper

我有一个结构x,在将它作为参数传递给函数之前,需要将其转换为其他形式。

例如,

static struct ss x = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}};

int out1 = function1( std::span<const a>(x))
int out2 = function2( std::span<const a>(x))
int out3 = function3( std::span<const a>(x))

出于将函数调用内部转换为std::span<const a>(x)的目的,我如何将x包装在函数中以返回类型std::span<const a>?

这样我就可以将函数调用为int out1 = function1( funx())

否则,用functionx作为类型为std :: span的参数调用x的最简单方法是什么

1 个答案:

答案 0 :(得分:1)

我认为这就是您想要的:span funx () { return span (x); }