Search Results

Search found 1 results on 1 pages for 'user173342'.

Page 1/1 | 1 

  • Overlapping template partial specialization when wanting an "override" case: how to avoid the error?

    - by user173342
    I'm dealing with a pretty simple template struct that has an enum value set by whether its 2 template parameters are the same type or not. template<typename T, typename U> struct is_same { enum { value = 0 }; }; template<typename T> struct is_same<T, T> { enum { value = 1 }; }; This is part of a library (Eigen), so I can't alter this design without breaking it. When value == 0, a static assert aborts compilation. So I have a special numerical templated class SpecialCase that can do ops with different specializations of itself. So I set up an override like this: template<typename T> struct SpecialCase { ... }; template<typename LT, typename RT> struct is_same<SpecialCase<LT>, SpecialCase<RT>> { enum { value = 1 }; }; However, this throws the error: more than one partial specialization matches the template argument list Now, I understand why. It's the case where LT == RT, which steps on the toes of is_same<T, T>. What I don't know is how to keep my SpecialCase override and get rid of the error. Is there a trick to get around this? edit: To clarify, I need all cases where LT != RT to also be considered the same (have value 1). Not just LT == RT.

    Read the article

1