Xav wrote:
#include <iostream>
using namespace std;
class CLog
{
public:
template<typename paramT>
CLog& operator<<(const paramT& param)
{
return *this;
};
};
int main()
{
CLog Log;
Log << endl; // no match for `CLog& << <unknown type>' operator
}
Why is endl type unknown ?
How can i do this ?
...
'std::endl' is a function template. It doesn't have a type until it is
specialized. You method is also template and its only parameter also
doesn't have a type until it is specialized. The compiler cannot perform
the specialization in this situation because it has nothing to start
from. You have to specialize at least one of these templates explicitly.
For example
Log << endl<char, char_traits<char> >;
--
Best regards,
Andrey Tarasevich