I want to determine if any variadic class template is the base of another class. Typically I'd use std::is_base_of, but I don't think my use case fits, and I'm not sure if there's already something in std or boost to handle this. I want the variadic base class template's parameter pack to come from another variadic class template. Here's some example code that hopefully explains what I want to do:
Usage:
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 this possible?
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>
{};
Hope it helps!
You're nearly there, but try it with a partial specialization:
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 >
{};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With