The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Attn: C++ gurus by nix 2003-10-22 13:35:28
Anyone know how to declare a template function within a template class?

Here's the original code. It works.

in class.h:
template <class T> class foobar {
...
CC <RR> blech_float(long params);
CC <RR> blech_double(long params);
...
}

and in class.cpp:
template <> CC <RR> foobar <ZZ> :: blech(long params) {
...
}


Here's my attempt to templatize it. g++ barfs at me.

in class.h:
template <class T> class foobar {
...
template <class TYPE> CC <RR> blech_float(long params);
...
}

and in class.cpp:
template <> template <class TYPE> CC <RR> foobar <ZZ> :: blech(long params) {
...
}


The error was
"enclosing class templates are not explicitly specialized"
"template-id 'blech<>' for 'NTL::CC<NTL::RR> NTL::foobar<NTL:ZZ>::blech(long int)' does not match any template declaration"
...

BTW, this isn't my code. I know it's ugly. And I know that class members inherit the class's template stuff; I'm trying to make this function generic over something else.

Any ideas?
[ Reply ]
  How was blech declared? by ToLazyToThink2003-10-22 14:35:26
    here's some exact code that has the same issue by nix2003-10-22 15:56:53
      BTW, the compiler was GCC 3.2.2 20030222 by nix2003-10-22 16:16:37
      Ok, I think I got it by sereth2003-10-22 17:29:03

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)