For example
template<typename... Ts>
LastTypeOfTs f();
How to return the last type of a variadic template?
You could do a template recursion as below:
template<typename T, typename... Ts>
struct LastTypeOfTs {
typedef typename LastTypeOfTs<Ts...>::type type;
};
template<typename T>
struct LastTypeOfTs<T> {
typedef T type;
};
template<typename... Ts>
typename LastTypeOfTs<Ts...>::type f() {
//...
}
LIVE DEMO
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