David Lichmann
David Lichmann

Reputation: 1506

C++ specializing variadic template inside of a variadic template

How do I specialize classes with variadic template parameters inside of classes with variadic template parameters? I.e.:

template < typename ... >
struct test_class
{
    template < typename ... >
    struct s { };
};

template < >
template < typename ... ts >
struct test_class< ts ... >::s< int > { }; // doesn't work

Is this even possible?

Upvotes: 1

Views: 87

Answers (1)

Ole
Ole

Reputation: 36

template <typename...>
struct OutsideS {
    // ...
};

template </* ... */>
struct OutsideS</* ... */> {
    // ...
};

template <typename... Types>
struct TestClass {
    template <typename... OtherTypes>
    using S = OutsideS<OtherTypes...>;
};

Specializing it in a nested way is not possible, but you can specialize the nested template somewhere else.

Upvotes: 2

Related Questions