I know how to select first parameter of variadic template:
template< class...Args> struct select_first;
template< class A, class ...Args> struct
Sorry for being a bit late to the party, but I just ran across the same problem , looked up for an answer, didn't like what I see here and realised it can be done using a tuple. Please see C++11 implementation below. Note: one can also get access to an Nth type of a variadic template this way. (The example doesn't check that N exceeds the number of variadic arguments , however the check can be done with SFINAE technique (enable_if) for instance) Is that an acceptable answer or I'm missing anything in the question?
#include
#include
struct A
{
char ch = 'a';
};
struct B
{
char ch = 'b';
};
struct C
{
char ch = 'c';
};
template
struct SomeVariadic {
using TypesTuple = std::tuple;
using LastType = typename std::tuple_element::type;
template
using NthType = typename std::tuple_element::type;
};
int main(int argc, char* argv[]) {
SomeVariadic::LastType l;
std::cout << SomeVariadic::LastType().ch << " "
<< SomeVariadic::NthType<1>().ch<< std::endl;
}