From: Paul D. <pa...@du...> - 2012-10-15 16:21:19
|
I'm missing something. I have a class like so: class foo { public: std::ostream& print(std::ostream& out) { out << m_value; return out; } private: int m_value; }; inline std::ostream& operator<<(std::ostream& out, const foo& f) { return f.print(out); } I am trying to stream an instance of foo to a CategoryStream. logger.infoStream() << "Foo: " << f; The compiler is balking about the "(*_buffer) << t;" statement in the operator<<() method template in CategoryStream saying that the call is ambiguous. It's suggesting operator<<() routines for a whole mess of base types but doesn't see the one for my class. This works: std::stringstream str; str << foo(); Why doesn't this? logger.infoStream() << foo(); Paul |