c++/45: Template Specialization

Wolfgang Bangerth bangerth@ticam.utexas.edu
Tue Oct 22 17:13:00 GMT 2002


Someone should re-name this report to
  "Matching of partial specialization of classes"

Here's a redux:
-----------------------------------------
template <int N>  struct Int {};
template <char C> struct Char{};

template <typename A, typename B> struct X;

template <char C, int N> struct X< Char<C>, Int<N> > { typedef Int<C> val; };
template <int N, char C> struct X< Int<N>, Char<C> > { typedef Int<N> val; };

X< Int<0>, Char<'1'> >::val i;
----------------------------------------

In ways I don't understand, this bug goes away if in the declaration of 
the second partial specialization, "int N" and "char C" is reversed, 
something that should have absolutely no effect on matching of templates. 
In some other ways I do not understand either, the problem also goes away 
if I change the template argument of "Char" from "char" to "int", 
something that should also not affect matching, but does.

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth




More information about the Gcc-bugs mailing list