I know how to select first parameter of variadic template:
template< class...Args> struct select_first;
template< class A, class ...Args> struct select_first<A,Args...>{ using type = A;};
It's a very simple. However, select_last is not similar:
template< class ...Args> struct select_last;
template< class A> struct select_last<A> { using type = A; };
template< class A, class Args...> struct select_last<A,Args...>{
using type = typename select_last<Args...>::type;
};
This solution needed deep recursive template instantinations.
I try to solve this with as:
template< class A, class Args...>
struct select_last< Args ... , A>{ using type = A; }; // but it's not compiled.
Q: exist more effective way to selecting last parameter of variadic templates?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…