You can do it in the following way:
template <class... Types>
struct Wrapper
{
template <Types... args>
class Test {
// ...
};
};
Note that simple notation template <class... Types, Types... args> class Test;
is not permitted by standard (see paragraph [temp.param] 14.1/15).
Example of using (note that float
, double
and long double
constants can not be non-type template parameters):
Wrapper<int, char, unsigned>::Test<1, '2', 3U> t;
More specific case with pointers to members can be implemented similarly:
struct Base
{
int a;
float b;
void c() {}
};
template <class... Types>
struct Wrapper
{
template <Types Base::*... args>
class Test {
//
};
};
Example of using:
Wrapper<int, float, void ()>::Test<&Base::a, &Base::b, &Base::c> t2;
This notation can be shortened using variadic macro and decltype
keyword.