dimanche 2 avril 2017

How to check a type is of a given template type

I have a template type:

template<class T>
struct Shadow {
   T field[100];
};

I want to create a tuple, whose types are instantiations of Shadow, but should not allow any other types. For example,

tuple< Shadow<int>, Shadow<double> > x; // correct instantiation.
tuple< Shadow<int>, double > x; // incorrect instantiation.

How can I achieve this (and have compiler flag an error in case of incorrect instantiation)?

Aucun commentaire:

Enregistrer un commentaire