Hello,
I am currently upgrading from boost-1.30.2 to boost-1.32.0 with MSVC 7.1 and I
am running into the following issue:
BOOST_CHECK_EQUAL requires the elements to be compared to provide an operator<<
taking an std::ostream& as first parameter. I always had names lookups problems
with that when the operator was provided by the test and not along with the
element. Until now, I had the operator defined in "boost" namespace (that's
ugly I know) in the test file. It breaks with 1.32.0 because the
problematic function (print_log_value) moved deeped into test tools
namespaces. Then I try to revert to a
normal definition but it does not work either. For instance :
//*******************************
#include
using boost::unit_test::test_suite;
namespace testns
{
struct Test
{
Test(std::string const& s_) : s(s_) {}
bool operator==(Test const& t) const
{
return s==t.s;
}
std::string s;
};
namespace
{
std::ostream& operator<<(std::ostream& o, Test const& t)
{
return o<add( BOOST_TEST_CASE( &testns::free_test_function ));
return test;
}
//***********************
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.
Note these workaround do not work or cannot be applied if the type is
declared by a typedef. In this case, I have to define again the
operator in namespace
boost.test_tools.tt_detail.
Is it to be expected ? Is is an ADL issue ? Or something related to
MSVC 7.1 ? What is the proper way to do that ?
Patrick Mézard