This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Template specialization problem


In the sample below I get the folowing error message:

spec.cc:30: template-id `toType<>' for `char X<char>::toType(int)' does
not
   match any template declaration
spec.cc:30: syntax error before `{' token

Is it a compiler bug or I misunterstod something?

Regards
-- 
Ryszard Kabatek


template<typename T>
struct X {
  typedef T type;
  typedef T itype;
 
  static type toType(itype i);
  static itype toItype(type c) {return static_cast<itype>(c);}
 
};
 
template<>
struct X<char> {
  typedef char type;
  typedef int itype;
 
  static type toType(itype i);
  static itype toItype(type c) {return static_cast<itype>(c);}
};

template<typename T>
X<T>::type
X<T>::toType(itype i)
{
  return static_cast<type>(i);
}
 
template<>
X<char>::type
X<char>::toType(itype i)
{
  return static_cast<type>(i);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]