I am using the Boost Unit Test library and have code that uses the
BOOST_CHECK_EQUAL macro with std::wstring instances. I get a
compilation error when I do this because there is no operator<< defined
for a narrow ostream and a wide string. So, I created one as shown
below, but I am still getting the exact same compilation error (using
MSVC 2003). With my new operators, I am able to manually insert wide
strings into a narrow ostream, but the BOOST_CHECK_EQUAL macro expansion
still doesn't seem to be picking it up. Any ideas?
Thanks,
Sean Rohead
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <string>
#include <iostream>
std::wstring widen(const std::string& source)
{
std::wstring result(source.size(), wchar_t(0));
typedef std::ctype
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
------ Build started: Project: boost, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\lib\boost_1_32_0\boost\test\test_tools.hpp(207) : error C2679: binary
'<<' : no operator found which takes a right-hand operand of type 'const
std::wstring' (or there is no acceptable conversion)
c:\lib\boost_1_32_0\boost\test\test_tools.hpp(206) : while
compiling class-template member function 'void
boost::test_tools::tt_detail::print_log_value<T>::operator
()(std::ostream &,const T &)'
with
[
T=std::wstring
]
c:\lib\boost_1_32_0\boost\test\test_tools.hpp(251) : see
reference to class template instantiation
'boost::test_tools::tt_detail::print_log_value<T>' being compiled
with
[
T=std::wstring
]
c:\lib\boost_1_32_0\boost\test\detail\wrap_stringstream.hpp(69)
: see reference to function template instantiation 'std::ostream
&boost::test_tools::tt_detail::operator <<<Left>(std::ostream &,const
boost::test_tools::tt_detail::print_helper<T> &)' being compiled
with
[
Left=std::wstring,
T=std::wstring
]
c:\lib\boost_1_32_0\boost\test\test_tools.hpp(438) : see
reference to function template instantiation
'boost::basic_wrap_stringstream<CharT> &boost::operator
<<