Here is the simplified problem.
template <class T>
std::string name(const T&); // This is the template
// I want to explicitly specialize.
class Outer
{
class Inner
{
};
class Container : public ::Container<Inner> // This causes also an implicit
// specialization of f::name
{
};
};
How can I specialize
template <class T>
std::string name(const T&);
for Outer::Inner ?
I cannot declare the explicit specialization in three places I considered:
template <class T>
std::string name(const T&);
// 1. Here I cannot forward declare a nested class
class Outer
{
class Inner
{
};
// 2. Here I get error: explicit specialization
// in non-namespace scope 'class Outer'
class Container : public ::Container<Inner>
{
};
};
// 3. Here I get error: specialization of '...' after instantiation
How can I solve this problem?
Have a look at this article. You might be better off just writing a
namefunction for the specific type you want to “specialize” for: