Ambiguous partial template specialization
ambiguity, c++, specialization, templates
Solution
Your best bet for this, if you can't avoid overlapping specialization, is to clarify all your overlaps. You'll need to write another specialization for
template< typename T> struct TRAIT< C<T>, C<T> > { };
...but, as everybody else said in the comments, it's best to avoid overlapping if at all possible. As others called out, the problem may not be overlapping specializations, it may be that this isn't the best approach to solve your problem.
Problem
I've got a trait class which I need to specialize (and partial-specialize) many times. Some partial specializations overlap: ``` template< typename T > struct C { }; template< typename T1, typename T2 > struct TRAIT { }; template< typename T > struct TRAIT< T, T > { }; template< typename T1, typename T2 > struct TRAIT< C<T1>, C<T2> > { }; int main( ) { // ERROR! could be both TRAIT<T,T> [with T = C<int>] // and TRAIT<T1,T2> [with T1 = T2 = int] TRAIT< C<int>, C<int> > foo; return 0; }; ``` How am I supposed to get the same result with a working code? I went crazy with `enable_if` and `is_same`, I'm not even sure anymore it's the right way...