N
Nick Bastin
I've done some searching in this newsgroup and on the internet and
haven't found an answer, so I thought I'd ask here...
I don't understand why full specialization of a member function
template in a class template is only valid if you fully specialize the
class template as well. Consider the following example:
[header]
template<class T, int ID>
class RSMixin : public T
{
...
template <typename T2>
void setAttribute (std::string name, T2 value);
}
[implementation]
template<class T, int ID>
template<>
void
RSMixin<T, ID>::setAttribute (std::string name, bool value)
{ }
I understand that this isn't valid, but I don't really understand the
rationale behind why.
RSMixin<GenericDriver, 0> foo;
foo.setAttribute ("some attribute", true);
should generate:
void RSMixin<GenericDriver, 0>::setAttribute(std::string, bool);
This seems unambiguous to me, but maybe someone can point out a more
difficult situation where the compiler wouldn't be able to figure it
out?
haven't found an answer, so I thought I'd ask here...
I don't understand why full specialization of a member function
template in a class template is only valid if you fully specialize the
class template as well. Consider the following example:
[header]
template<class T, int ID>
class RSMixin : public T
{
...
template <typename T2>
void setAttribute (std::string name, T2 value);
}
[implementation]
template<class T, int ID>
template<>
void
RSMixin<T, ID>::setAttribute (std::string name, bool value)
{ }
I understand that this isn't valid, but I don't really understand the
rationale behind why.
RSMixin<GenericDriver, 0> foo;
foo.setAttribute ("some attribute", true);
should generate:
void RSMixin<GenericDriver, 0>::setAttribute(std::string, bool);
This seems unambiguous to me, but maybe someone can point out a more
difficult situation where the compiler wouldn't be able to figure it
out?