To properly transmit a decltype(auto)
variable from a function, you can use either auto
or decltype
to declare the variable in the receiving function.
For example, in the sending function, you can have:
decltype(auto) var = some_function();
return var;
And in the receiving function, you can have:
auto var2 = sending_function();
or
decltype(var) var2 = sending_function();
Either way, the decltype(auto)
variable will be correctly transmitted and stored in the receiving function as auto
or with the same type as the original variable using decltype
.
Asked: 2023-04-03 11:00:00 +0000
Seen: 8 times
Last updated: Jul 03 '22