Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Warning (Anachronism): Old explicit specialization syntax

807575Sep 1 2006 — edited Sep 1 2006
I have the situation where in my header I have a template class thus:

template<typename T>
class foo
{
public:
void doSomethingInteresting()
};

then in my .cpp file

void foo<double>::doSomethingInteresting()
{
//do something with doubles
}

void foo<int>::doSomethingInteresting()
{
//do something with ints
}

It compiles fine in VC++, GCC, and Sun C++ 5.8 Patch 121017-02

However with the Sun compiler I get the message:
Warning (Anachronism): Old explicit specialization syntax

If the template function does not have a parameter that is of type T then there are no clues for the compiler to distinguish the different template specialisations, except by using the syntax foo<int>::doSomethingInteresting.

If my syntax is out of date what is the correct one? I do not want in a couple of years to find out that my code ceases to complile as this old syntax is out of date and there is no replacement.

The design of these functions is that the caller does not know or cares about the type of the template parameter T. I can replace it all with virtual non template class functions, but it would mean writing dozens of extra classes.

Regards

Edward
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2006
Added on Sep 1 2006
2 comments
297 views