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.
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@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of steve ahlgren Sent: Friday, February 18, 2005 9:54 AM To: boost-users@lists.boost.org 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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Delfin Rojas
-
steve ahlgren