The following piece of code demonstrates the problem:
class Printer
{
public:
template<int i = 2>
void print() { cout << i; }
};
template<typename T>
class Base
{
protected:
Printer printer;
};
template<typename T>
class Derived : public Base<T>
{
public:
void foo()
{
this->printer.print<5>(); // the error happens here
}
};
The error from GCC says "invalid operands of types (...) to binary ‘operator<’". For this reason I believe that it is a problem with parsing, I have tried using the template keyword, but to no avail so far.
When I use the default template parameter and call the function of the printer object in the following way, everything is fine.
this->printer.print();