Hi, it has been a while since I created a thread in this forum.
I'm having trouble with specializing a templated function inside a templated class. If the class is a regular class it works fine, but I need the class to be templated too.
Here's a class with everything unimportant stripped off:
Code:
template<class C>
class Logger
{
public:
template<typename T>
void log(T str);
};
//Main definition (works)
template<class C>
template<typename T>
void Logger<C>::log(T str)
{
}
//Specialization for ints
template<class C>
template<>
void Logger<C>::log<int>(int str)
{
}
How do I accomplish that last specialization? As of now, it doesn't work.
Here's how it would look if the class wasn't templated and this works:
Code:
class Logger
{
public:
template<typename T>
void log(T str);
};
template<typename T>
void Logger::log(T str)
{
}
template<>
void Logger::log<int>(int str)
{
}