lexical_cast problem with Unicode
I have problems compiling the following piece of code under Microsoft Visual C++
6.0 with UNICODE defined. The compiler complains about a missing operator<<.
What can I do in order to get this programme compiled ?
#include <iostream>
#include
stream_char<Target>::type and stream_char<Source>::type are both char instead of wchar_t.
From: "Stefan Felkel"
I have problems compiling the following piece of code under Microsoft Visual C++ 6.0 with UNICODE defined. The compiler complains about a missing operator<<. What can I do in order to get this programme compiled ?
#include <iostream> #include
int main( int argc, char * argv [] ) { std::wcout << boost::lexical_caststd::wstring( std::wstring( L"test" ) ).c_str() << L"\n";
return 0; }
c:\programme\boost_1_30_0\boost\lexical_cast.hpp(148): error C2679: binary '<<': no operator defined which takes a right-hand operand of type 'const wstring' (or there is no acceptable conversion)
c:\programme\boost_1_30_0\boost\lexical_cast.hpp(146): while compiling class-template member function 'bool boost::detail::lexical_stream
::operator <<(const wstring &)'
MSVC 6.0 has no intrinsic wchar_t (it's a synonym for unsigned short), so it treats wchar_t as unsigned short, in other words an integer, and the same goes for std::wstring. In order to not break the use with other libraries (like Boost Date/Time, which uses unsigned short), lexical_cast has wide character support turned off when there's no intrinsic wchar_t. Therefore, you can't use lexical_cast with wide characters/strings on MSVC 6. It works on MSVC 7, though, which has an (optional) intrinsic wchar_t. Regards, Terje
participants (3)
-
Stefan Felkel
-
stefan_felkel2000
-
Terje Slettebø