Search code examples
c++wrapper

Wrap with a function to return a different type


I have a struct x which needs to be converted to something else before it is given to a function as an argument.

For example,

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))

Insted of converting inside the function call as std::span<const a>(x), how do I wrap x inside a function to return in the type std::span<const a>?

So that I can call the functions as int out1 = function1( funx())

Else, what is the most simple way to call functionx with x as the argument of type std::span


Solution

  • I think this is what you want: span funx () { return span (x); }.