Boost logo

Boost Users :

From: Delfin Rojas (drojas_at_[hidden])
Date: 2005-02-18 14:07:42


Hi Steve,

The first one:

int foo = boost::lexical_cast< int >( std::wstring( L"1" ) ); should work. I
do it all the time. However, I believe you have to set "treat wchar_t as
built in type" in your VC++ 7.1 project settings.

You cannot use lexical cast to convert from string to wstring and back. My
suggestion is to write a string_cast<char type> that uses the proper Win32
functions to do the conversion.

-delfin

> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of steve ahlgren
> Sent: Friday, February 18, 2005 9:54 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] lexical_cast and wstring on VC 2003
>
> Hello :
>
> I would like to use lexical_cast to convert to/from std::wstring on vc
> 2003 but I'm failing.
>
> These fail :
>
> int foo = boost::lexical_cast< int >( std::wstring( L"1" ) );
> std::string bar = boost::lexical_cast< std::string
> >( std::wstring( L"a" ) );
> std::wstring fred = boost::lexical_cast< std::wstring >( std::string(
> "Fred" ) );
>
> Any hints would be greatly appreciated and kindly rewarded with good
> programming karma.
>
> Thanks in advance;
> Steve a.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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