To extract the package of parameters of the variational template and use it in another variational template in the metafunction of the type?

I want to determine if any template of a variational class is the base of another class. I usually use std :: is_base_of, but I don't think my use case is suitable, and I'm not sure if there is already something in std or boost to handle this. I want the package of parameters of the variational base class template to come from another variational class template. Here is an example code that hopefully explains what I want to do:

Using:

is_variadic_base_of<
   VarClassTemplA
   , ClassDerivedFromA
   , VarClassTemplB //Has param pack I want to use with ClassA
>::value;

Guts:

//test for variadic base of non-variadic
template <template<typename...> class A, typename B, typename... ArgsC>
struct is_variadic_base_of
: std::is_base_of<A<ArgsC...>, B>
{};

Is it possible?

+5
source share
2 answers
template <template<typename...> class A, typename B, typename ArgsC>
struct is_variadic_base_of;

template <template<typename...> class A, typename B, 
          template<typename...> class C, typename ...ArgsC>
struct is_variadic_base_of<A, B, C<ArgsC...>> 
: std::is_base_of<A<ArgsC...>, B>
{};

, !

+5

, :

template<
    template<class...> class A, class B, class C
>
struct is_variadic_base_of;

// partial spec
template<
    template<class...> class A, class B,
    template<class...> class C, class... ArgsC
>
struct is_variadic_base_of< A,B,C<ArgsC...> >
  : std::is_base_of< A<ArgsC...>,B >
{};
+4