![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Oct 2008
Posts: 3
| inline templated class method as standalone function in namespace 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
}
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 |
| monikersupreme is offline | |
| | #2 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| The code compiles fine, if <string> and <set> are included and StringException is declared. What compiler are you using? By the way, throw specifications are a misfeature and do more harm than good. Get rid of them.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #3 | |
| Registered User Join Date: Oct 2008
Posts: 3
| Thanks for the response... Quote:
Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 I guess I'm off to see if there is any documented compiler bug relevant to this issue... | |
| monikersupreme is offline | |
| | #4 |
| Registered User Join Date: Oct 2008
Posts: 3
| |
| monikersupreme is offline | |
| | #5 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
|
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
![]() |
| Tags |
| inline, parameter, template |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting an error with OpenGL: collect2: ld returned 1 exit status | Lorgon Jortle | C++ Programming | 6 | 05-08-2009 08:18 PM |
| Game Pointer Trouble? | Drahcir | C Programming | 8 | 02-04-2006 02:53 AM |
| Post... | maxorator | C++ Programming | 12 | 10-11-2005 08:39 AM |
| class errors | romeoz | C++ Programming | 3 | 09-16-2003 07:57 PM |
| Predeclaration of template class in namespace | unregistred | C++ Programming | 0 | 05-30-2003 03:52 AM |