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 Again



Hi.

I am now studing about template specialization using EGCS-1.1.1.

I read about specialization support of egcs in this list archieve, 
and also compile the sample code by Jean-Michel Paris in there.
This works well as stated there.

But I also tested function template specialization by this code:

#include <iostream.h>
#include <string>

template <class T> void f(T x){ 
  cout << "most general" << endl;
}

template <class T> void f<T *>(T x){ // error at this line!
  cout << "pointer version" << endl;
}

int main(int argc,char *argv[]){

  string str = "shinke";
  string *p = &str;

  f(str);
  f(p);
  
  return 0;
}

It causes complile error at <T *>-template declaration.

>template-id `f<T *>' in declaration of primary template
>spectest.cpp:8: redefinition of `template <class T> void f(T)'
>spectest.cpp:4: `template <class T> void f(T)' previously declared here

Dose it mean that egcs dosen't support this type of specialization yet?
Or I do somthing incorrect?


-----
Hirofumi SHINKE
shinke@{bisd.hitachi.co.jp,newhouse.rim.or.jp}









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