I often use this macro to perfectly forward a parameter without having to know the type of the parameter:
#define FORWARD(a) std::forward<decltype(a)>(a)
I now want to get rid of the macro and therefore I'm searching for an equivalent definition of a function in c++ which can be used interchangeably with the macro.
This may be a simplistic example, but for the record: I want code like this to compile correctly with arbitrary types for Param{A,B}
- without having to use the expanded form everywhere (like std::forward<decltype(a)>(a)
).
decltype(auto) operator Op(ParamA a, ParamB b) {
return Forward(a) Op Forward(b);
}
Hint: Not a duplicate of this question