The following test code compiles and executes correctly:
However when I attempt to incorporate this as a standalone inline function in a namespace (and not as part of a class):Code:class RegExpTest : public Framework { template <class T> int reParseNumbers( std::string, std::set<T>&, double=-1 ) throw(Exception ); } template <class T> int RegExpTest::reParseNumbers( std::string s, std::set<T> & numSet, double set_size_limit ) throw( Exception ) { // do some regular expression stuff and return an int }
I get the following error messages:Code:namespace StringFunctions { template <class T> inline int reParseNumbers( std::string s, std::set<T> & numSet, const double set_size_limit=-1 ) throw( StringException ); template <class T> inline int reParseNumbers( std::string s, std::set<T>& numSet, const double set_size_limit ) throw( StringException ) { // do some regular expression stuff and return an int } }
"StringFunctions.hpp", line 5: Error: Templates can only declare classes or functions.
"StringFunctions.hpp", line 11: Error: Templates can only declare classes or functions.
I've narrowed the problem with the second code example down to the second std::set<T> parameter that is being passed. Although the code compiles fine as part of my test class, when it is included as a standalone inline'd function in a namespace, the compiler chokes on the second std::set<T> parameter with the error message above.
What should I do differently to inline a templated method standalone in a namespace (as opposed to having it as part of a class)?
Any advice would be much appreciated



LinkBack URL
About LinkBacks



CornedBee