template<typename T1, typename T2> class A{}; template<typename T> using Specialization_1 = A<T, int>; template<typename T> using Specialization_2 = A<T, double>; template<typename T> using Specialization_3 = A<int, T>; 

Can you specify such a template so that it means only the following:

1) Specialization_1 || Specialization_2 Specialization_1 || Specialization_2

2) Specialization_1 || Specialization_3 Specialization_1 || Specialization_3

3) Specialization_2 || Specialization_3 Specialization_2 || Specialization_3 ?

  • "Can I specify this type ...". It is unclear what you mean. There is not a single type among the above, but there are only type templates (class templates) .. - AnT
  • @AnT fixed the question - kqer
  • What does “or” mean between the two types? If I were you, I would describe the real task, and not this question, because, in my opinion, you are not trying to do something. - ixSci
  • @ixSci need a template that means either one or another template - kqer
  • And what does that mean? How will be determined which one is needed? - ixSci

1 answer 1

Perhaps the author wants to see:

  template<typename T1, typename T2> using Specialization_2_or_3 = typename std::enable_if< std::is_same<T2,double>::value || std::is_same<T1,int>::value , A<T1, T2> >::type; Specialization_2_or_3<int, int> a1; // ok Specialization_2_or_3<double, int> a2; // error 

?