If I have two variadic template arguments, A and B, how can I ensure at compile-time that the types of all of the members of A are also the types of a subset of B (in the same order)?
Contrived example:
template<typename...A>
struct Foo {
template<typename...B>
static void bar()
{
}
}
...
Foo<Apple, Orange>:: template bar<Apple, Orange, Grape>(); // this compiles
Foo<Apple, Orange>:: template bar<Orange, Grape>(); // this doesn't
For a general subset I don’t know, but if you can guarantee that
Bis of the formA..., More..., then this may do:(Sorry,
var_equalis a terrible name. It should be called something more appropriate, likeinitial_equal.)Update: Here is the general solution, worked out in detail by Luc Danton (see here for his beautifully styled code):
Test case: