This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Template Specialization Again
- To: egcs at egcs dot cygnus dot com
- Subject: Template Specialization Again
- From: Hirofumi SHINKE <shinke at newhouse dot rim dot or dot jp>
- Date: Mon, 15 Feb 1999 01:03:19 +0900
- Cc: shinke at newhouse dot rim dot or dot jp
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}