I want to write a function
template <class T>
X foo (T);
where T is of type std::pair<X, X>.
How can I deduce the return type X from T?
In your example X has to be templated, too:
template <class T, class X = typename T::first_type >
X foo (T t);
But better would be:
template <class T >
typename T::first_type foo (T t);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With