$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] How to make boost.test log wstring?
From: Alexey Badalov (don_reba_at_[hidden])
Date: 2010-02-06 04:54:39
"Gennadiy Rozental" <rogeeff_at_[hidden]> wrote in message 
news:loom.20100206T071834-814_at_post.gmane.org...
> You can send in a patch which will make Boost.Test work with both ostream 
> and
> wostream. Also you cna write an operator << (ostream&,wstring const&)
I tried to put the operator above "#include <boost/test/unit_test.hpp>", but 
the same error persists, and mine is not in the candidate operator overload 
list displayed in the message - only operators defined in <ostream> are 
listed. My operator lets me output wstrings to std::cout from test cases, 
but when "boost\test\test_tools.hpp" tries to do it, it does not compile.
I am using boost 1.41.0 and vc9. Here is my code and the error:
#include <iostream>
#include <string>
std::ostream & operator << (std::ostream & stream, const std::wstring & str)
{
    return stream << "std::wstring";
}
#define BOOST_TEST_MODULE const_string test
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(Test)
{
    std::wstring wstr;
    std::cout << wstr; // OK
    BOOST_CHECK_EQUAL(wstr, wstr); // Error
}
test.cpp
...\boost\test\test_tools.hpp(326) : error C2679: binary '<<' : no operator 
found which takes a right-hand operand of type 'const std::wstring' (or 
there is no acceptable conversion)
 ...
        while trying to match the argument list '(std::ostream, const 
std::wstring)'
        ...\boost\test\test_tools.hpp(318) : while compiling class template 
member function 'void boost::test_tools::print_log_value<T>::operator 
()(std::ostream &,const T &)'
        with
        [
            T=std::wstring
        ]