(Using NT 4.0, CW R6, compiler version 2.3.1, __MWERKS__ == 0x2301)
I'm writing a stream class. It includes a member function template to
generically support writing out objects of any type. It looks like this
(simplified for illustration) --
struct ObjectStream
{
template <class T>
void WriteObject( const T & obj ) { /* ...do stuff... */ }
};
This works, PROVIDED that the member template body is defined inside the
class declaration. But I want to move it down outside the class body, for
readability and compliance with our coding standards. I believe the syntax
outside the class is supposed to be something like this:
template <class T>
void ObjectStream::WriteObject( const T & obj ) { /* ... */ }
But this doesn't work -- the CW compiler complains about an illegally
defined template. (I've tried it with the "<T>" part omitted and in
different places, but nothing works.) I believe this _is_ supposed to be
legal C++, though my truckload of C++ books fails me at the moment.
So, does anybody know if the CodeWarrior compiler is supposed to support
this, or not support it, or if I'm making some other error here?
-slj-
(BTW, I'm not looking for help writing a stream class or any other
implementation advice. Just worrying about the specific C++
language/compiler issue presented above.)
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html