Boost logo

Boost :

Subject: [boost] [Test] Problem testing with wstring
From: Jared McIntyre (jmcintyre_at_[hidden])
Date: 2009-08-26 00:46:13


I'm having an issue testing against wstrings:

std::wstring testString("");
BOOST_CHECK_EQUAL(testString,L"");

This fails with the following error:

std_map.cpp: In member function ‘void
vector_in_map_stream_test::test_method()’:
std_map.cpp:83: error: no matching function for call to
‘std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >::basic_string(const char [1])’
/usr/include/c++/4.0.0/bits/basic_string.tcc:232: note: candidates
are: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(typename
_Alloc::size_type, _CharT, const _Alloc&) [with _CharT = wchar_t,
_Traits = std::char_traits<wchar_t>, _Alloc = std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:225:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT =
wchar_t, _Traits = std::char_traits<wchar_t>, _Alloc =
std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:218:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _CharT*, typename _Alloc::size_type, const
_Alloc&) [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>,
_Alloc = std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:207:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const std::basic_string<_CharT, _Traits,
_Alloc>&, typename _Alloc::size_type, typename _Alloc::size_type,
const _Alloc&) [with _CharT = wchar_t, _Traits =
std::char_traits<wchar_t>, _Alloc = std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:196:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const std::basic_string<_CharT, _Traits,
_Alloc>&, typename _Alloc::size_type, typename _Alloc::size_type)
[with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>, _Alloc =
std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:182:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const std::basic_string<_CharT, _Traits,
_Alloc>&) [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>,
_Alloc = std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.tcc:190:
note: std::basic_string<_CharT, _Traits,
_Alloc>::basic_string(const _Alloc&) [with _CharT = wchar_t, _Traits =
std::char_traits<wchar_t>, _Alloc = std::allocator<wchar_t>]
/usr/include/c++/4.0.0/bits/basic_string.h:2027: note:
std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with
_CharT = wchar_t, _Traits = std::char_traits<wchar_t>, _Alloc =
std::allocator<wchar_t>]
/Users/jared/Source/boost_nobak/boost_1_39_0/boost/test/
test_tools.hpp: In member function ‘void
boost::test_tools::print_log_value<T>::operator()(std::ostream&, const
T&) [with T = std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >]’:
/Users/jared/Source/boost_nobak/boost_1_39_0/boost/test/test_tools.hpp:
467: instantiated from ‘std::ostream&
boost::test_tools::tt_detail::operator<<(std::ostream&, const
boost::test_tools::tt_detail::print_helper_t<T>&) [with T =
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> >]’
/Users/jared/Source/boost_nobak/boost_1_39_0/boost/test/utils/
lazy_ostream.hpp:74: instantiated from ‘std::ostream&
boost::unit_test::lazy_ostream_impl<T>::operator()(std::ostream&)
const [with T = const
boost
::test_tools::tt_detail::print_helper_t<std::basic_string<wchar_t,
std::char_traits<wchar_t>, std::allocator<wchar_t> > >&]’
std_map.cpp:110: instantiated from here
/Users/jared/Source/boost_nobak/boost_1_39_0/boost/test/test_tools.hpp:
326: error: no match for ‘operator<<’ in ‘ostr << t’
/usr/include/c++/4.0.0/bits/ostream.tcc:67: note: candidates are:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)
(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:78: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)
(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:90: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT
= char, _Traits = std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:125: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(long int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:159: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:102: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(bool) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/ostream:176: note:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(short int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/ostream:187: note:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits
= std::char_traits<char>]
/usr/include/c++/4.0.0/ostream:191: note:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/ostream:202: note:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:183: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(long long int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:218: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(long long unsigned int) [with _CharT = char,
_Traits = std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:242: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(double) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/ostream:217: note:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(float) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:265: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(long double) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:288: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(const void*) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/4.0.0/bits/ostream.tcc:311: note:
std::basic_ostream<CharT1, Tr>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with
_CharT = char, _Traits = std::char_traits<char>]

Is this something that can be worked around without having to convert
the string to char?

Thanks,

Jared


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk