How would a constructor and a copy constructor look for this variadic template class?
struct A {};
struct B {};
template < typename Head,
typename... Tail>
struct X : public Head,
public Tail...
{
X(int _i) : i(_i) { }
// add copy constructor
int i;
};
template < typename Head >
struct X<Head> { };
int main(int argc, const char *argv[])
{
X<A, B> x(5);
X<A, B> y(x);
// This must not be leagal!
// X<B, A> z(x);
return 0;
}
Inside the template class,
Xas a type meansX<Head, Tail...>, and allXwith different template parameters are distinct types, so the copy constructor ofX<A,B>won’t matchX<B,A>.Demo: http://ideone.com/V6g35