I have a situation similar to this:
template<class A, class B>
class MyClass<A, B>
{
...
static A RARELY_USED_A;
}
// Seems to work but does not cover all possible cases, since
// there may be instances of A that have no numeric limits.
template<class A, class B>
A MyClass<A, B>::RARELY_USED_A= std::numeric_limits<A>::max();
From what I saw this seems to work. However, strings may be used as A under some circumstances and so I thought I'd simply create a specialization for this special case.
// Does not complile
template<class B>
string MyClass<string, B>::RARELY_USED_A= "";
unfortunately this does not complie properly with error msg:
error: template definition of non-template 'std::string MyClass<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, B>::RARELY_USED_A'
Note that, on the othre hand, a full specialization seems to work (untested at runtime but compiles)
// This complies but is not gernic enough and hence useless to me
template<>
string MyClass<string, string>::RARELY_USED_A= "";
I assume, I must be doing something wrong. I would be really grateful if you could point out what exactly it is. I thought partical specializations were supposed to work this way.
Thanks a lot in advance.
e: edited the name of the DEFAULT_A to RARELY_USED_A, because I thought that "default" was misleading somehow