metafunkcja szablonu do wykrywania specjalizacji szablonów
Zainspirowany przezto pytanie, zastanawiam się, czy istnieje jakaś kontrola podczas kompilacji, którą można wprowadzić, aby wykryć, czy dwie podane instancje szablonów:
template <typename T>
class Templ...
typedef Templ<std::string> stringInstance;
typedef Templ<double> doubleInstance;
są zbudowane z tej samej definicji lub są zbudowane z różnych specjalizacjiTempl
szablon
więc zasadniczo hipotetyczna funkcja szablonu będzie się zachowywać tak:
template <typename T>
class Templ
{}
template <>
class Templ<std::string>
{}
template <>
class Templ<double>
{}
template <typename T1,typename T2>
class Belong_To_Same_Templ_Definition
{}
//tests
typedef Templ<std::string> stringInstance;
typedef Templ<double> doubleInstance;
typedef Templ<int> intInstance;
typedef Templ<char> charInstance;
assert( Belong_To_Same_Templ_Definition< intInstance , charInstance >::value == true);
assert( Belong_To_Same_Templ_Definition< intInstance , doubleInstance >::value == false);
assert( Belong_To_Same_Templ_Definition< stringInstance , doubleInstance >::value == false);
możliwe jest stworzenie tego rodzaju metapunkty?