I have a templated class with an templated member function
template
class A {
public:
template
CT function();
};
You can use overload, if you change the implementation.
template <typename T>
class Foo
{
public:
template <typename CT>
CT function() { return helper((CT*)0); }
private:
template <typename CT>
CT helper(CT*);
T helper(T*) { return (T)0.0; }
bool helper(bool*) { return false; }
};
Simple and easy :)
Yes, this is the problem:
error: enclosing class templates are not explicitly specialized
You cannot specialize a member without also specializing the class.
What you can do is put the code from function
in a separate class and specialize that, much like basic_string depends on a separate char_traits class. Then then non-specialized function
can call a helper in the traits class.