I was working on a SFINAE programme to remove function template instances from the programme if the parameter class or template class is not a base of the collection (see How to get a SFINAE expression to work with template and non-template classes?):
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Classes to test on
class A{};
template <typename T> class B{};
template <typename T0, typename T1> class BB{};
class C{};
template <typename T> class D{};
template <typename T0, typename T1> class DD{};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Collection of valid types
template <
template <typename...> class TT
, typename...Ts>
class collection
: A // class A
, B<get_item<0,Ts...>> // class B<X>
, BB<get_item<0,Ts...>, get_item<1,Ts...>> // class BB<Y, Z>
{};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function to enable on
template <typename T>
enable_if_is_base_of<T, collection> test(T&&)
{ return enable_if_is_base_of<T, collection>();
}
Now I was wondering if the specifications of B<X>
or BB<Y,Z>
where they are defined as being base of collection
can somehow become inverted from BB<get_item<0,Ts...>, get_item<1,Ts...>>
to template_with_params<BB, ...Ts>
, or even template_with_params<BB, 2, ...Ts>
. Possible?
Aucun commentaire:
Enregistrer un commentaire