Vladimir Prus
Patrick M?zard wrote:
namespace testns {
struct Test { .... };
namespace {
std::ostream& operator<<(std::ostream& o, Test const& t) { return o<
...
Does not compile and gives me a: C2679: binary 'operator' : no operator defined which takes a right-hand operand of type 'const testns::Test' (or there is no acceptable conversion), the failure being issued by "void boost::test_tools::tt_detail::print_log_value<T>::operator ()(std::ostream &,const T &)"
However, if I define operator<< as a public member of testns::Test it compiles. Same thing if I move it outside the anonymous namespace, with or without static linkage.
I think defining operator<< in the same namespace as the class 'Test' is the only way. Otherwise, it won't be found by ADL and ADL is the only way to boost.test to find your operator<<.
Thank you for your answer. I did not know that ADL treats normal and anonymous
namespaces differently (and cannot find anything related in google.groups or
other mailing lists).
However, it does not work with typedefed types. Here is a new example :
//*********************
#include