Partial template specialization: matching on properties of specialized template parameter

Posted by Kenzo on Stack Overflow See other posts from Stack Overflow or by Kenzo
Published on 2010-05-29T06:13:04Z Indexed on 2010/05/29 6:22 UTC
Read the original article Hit count: 340

template <typename X, typename Y> class A {};
enum Property {P1,P2};
template <Property P> class B {};
class C {};

Is there any way to define a partial specialization of A such that A<C, B<P1> > would be A's normal template, but A<C, B<P2> > would be the specialization?

Replacing the Y template parameter by a template template parameter would be nice, but is there a way to partially specialize it based on P then?

template <typename X, template <Property P> typename Y> class A {};
// template <typename X> class A<X,template<> Y<P2> > {}; <-- not valid

Is there a way by adding traits to a specialization template<> B<P2> and then using SFINAE in A?

© Stack Overflow or respective owner

Related posts about c++

Related posts about sfinae