Hi!

I'm using log4cxx from SVN revision 486683, on a x86 Gentoo Linux system.

According to http://issues.apache.org/jira/browse/LOGCXX-150 logstream has
a problem with classes inside a namespace with a operator<<(...), which
happens to be my case.

I moved all operator<<(...) definitions of stream.h and logstream.cpp
inside the log4cxx namespace, which solved the problem, but other one just
appeared.

The code:

// MyClass has a friend ostream& operator<<( ostream& os, const MyClass& m )

MyNamespace::MyClass m;

log4cxx::logstream Log( some_logger, log4cxx::Level::DEBUG );

Log << m << LOG4CXX_ENDMSG;

results on a compilation error with lots of basic_ostream errors.
Basically the compiler can't decide what is the correct operator<<(...) it
must use.

The only way I have found to get rid of the problem was to define an extra
operator:

log4cxx::logstream& operator<<( log4cxx::logstream& os, const MyClass& m )

Everything then worked as expected, but it's a little cumbersome to define
2 operators per class (using a template on the first argument resulted on
the same indecision from the compiler).

Any hints about what could possibly be wrong?

Thanks a lot, Cantão!


Reply via email to