Template methods of a template class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a segment of code which compiles and runs fine under g++ 3.3.3 but
not under 2.91.60 which is unfortunately what I am stuck using for the time
being. I have given a *very* artificial example below (also in .cpp file
attached) but the crux is that I can't seem to explicitly specify the
template parameters for a template function within a template class in
2.91.60.

Does anyone know if this is a limitation of the template code in the earlier
g++ or is there some trick to getting this to work? Any help would be
appreciated...

Regards
 Stuart


>>>> EXAMPLE

template<class T> class MyTemplate
{
 public:

  template<class C> C convert();
  T value;
};

template<class T> template<class C> C MyTemplate<T>::convert() { return
(C)value; }

...

MyTemplate<int> base_template;
base_template.value=100;

float f=base_template.convert<float>();

* The error is "syntax error before '<'"

Attachment: testprog.tgz
Description: Binary data


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux