Boost logo

Boost Users :

From: Terje Slettebų (tslettebo_at_[hidden])
Date: 2004-12-27 05:02:11


>Georgios Diamantopoulos <georgiosd_at_[hidden]>:
 
> I am trying to convert from wchar_t to std::string with
>
> #include <iostream>
> #include <sstream>
> #include <boost/lexical_cast.hpp>
>
> int main()
> {
> std::cout << boost::lexical_cast<std::string>(L"blah") << std::endl;
> return 0;
> }
>
> but I get the following error:
> d:\SDK\boost\include\boost-1_32\boost\lexical_cast.hpp(158) : error
> C2679: binary '=' : no operator found which takes a right-hand operand
> of type 'std::basic_stringstream<_Elem,_Traits,_Alloc>::_Mystr' (or
> there is no acceptable conversion)
>
> Any ideas? This is with boost 1.3.2 and VC7.1

lexical_cast won't convert between char and wchar_t (or strings of these). To
convert from a wchar_t string literal, you need to convert to std::wstring.

Regards,

Terje


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net