Boost logo

Boost Users :

From: Tony Djordjevski (tony_at_[hidden])
Date: 2004-04-30 11:29:48


Hi,

I'm using Boost 1.31.0 with VC++ 7.1 and I'm having some problems converting
std::string to std::wstring and back.

Here's the code that I'm trying to get to compile:

std::wstring x = boost::lexical_cast<std::wstring>(
                        std::string("this doesn't work"));

std::string y = boost::lexical_cast<std::string>(
                        std::wstring(L"neither does this"));

The error I get for string to wstring:

lexical_cast.hpp(150): error C2679: binary '>>' : no operator found which
takes a right-hand operand of type 'std::wstring' (or there is no acceptable
conversion)

And the errors I get for wstring to string:

lexical_cast.hpp(144): error C2679: binary '<<' : no operator found which
takes a right-hand operand of type 'const
std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
        with
        [
            _Elem=wchar_t,
            _Traits=std::char_traits<wchar_t>,
            _Ax=std::allocator<wchar_t>
        ]
lexical_cast.hpp(144): error C2228: left of '.fail' must have
class/struct/union type

Any ideas of what I'm doing wrong?

Best Regards,
Tony Djordjevski


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