Consider the following function:
template<class T1, class T2, class T3 = /* SOMETHING */>
T3 f(const T1& x, const T2& y);
I want T3 to be equal to the return type of T1+T2. How to do that with C++11 ?
Note: I don’t want the result of std::common_type<T1, T2>::type, I want real type of T1+T2, considering that the operator+ can be a non-member function or can be a member function of T1.
The usual way is
decltypeand a trailing-return-type: