This compiles with out problems in VS 2009? Am I stupid?
GCC gives a warning, that the template is private….?
What am I missing?
#include <iostream>
using namespace std;
class A
{
private:
template<typename T>
A& operator<<(const T & v)
{
cout << v << endl;
return *this;
}
};
int main()
{
A a;
a << 4;
system("pause");
}
This code should not compile – this is a bug (or silly extension) in VS. GCC should refuse it as well. The operator is inaccessible in the scope it is used.
Comeau treats this correctly:
EDIT: A relevant standard snippet, from 13.3/1