2 ms·
It was added in C++11 when they added decltype(), so that you could reference arguments when computing return type. It's slightly different though, in that you
by int_19h 10y ago
It was added in C++11 when they added decltype(), so that you could reference arguments when computing return type. It's slightly different though, in that you need to specify the return type in the usual position as "auto" first, and then you can use "->" after the parameter list. So:
template<typename A1, typename A2>
auto foo(A1 a1, A2 a2) -> decltype(a1 + a2) {
return a1 + a2;
}