I have a class which I'm trying to stream directly into (I'm not streaming the class into an ostream, but actually streaming text into the class) by overriding the << operator. The class is essentially used so we can toggle debug output on and off for different parts of the project. However, when I try to use the operator, I get an undefined reference.
This is what's in my .h as a public member of the class
template <typename T>
DebugOutputStreamer& operator<<(T const& value);
And this is in my .cpp
template <typename T>
DebugOutputStreamer& DebugOutputStreamer::operator <<(T const& value)
{
if(m_Enabled)
{
if(m_UseColors)
{
std::cout << m_OuputColour << value << ConsoleColour::FG_DEFAULT;
}
else
{
std::cout << value;
}
}
return this;
}
However when I try to stream "Hello" in, I'm getting
main.cpp:(.text+0x564): undefined reference to `DebugOutputStreamer& DebugOutputStreamer::operator<< <char [6]>(char const (&) [6])'
Could anybody tell me what I'm missing?