C++可变参数模板中的专用可变参数模板

C++ specializing variadic template inside of a variadic template

本文关键字:参数 变参 专用 C++      更新时间:2023-10-16

如何在具有可变参数模板参数的类中专门化具有可变参数模板参数的类? 即:

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

这可能吗?

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

嵌套方式专用它是不可能的,但您可以在其他地方专用化嵌套模板。