Boost logo

Boost Users :

Subject: Re: [Boost-users] lexical_cast<unsigned char>: Compiler error
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-03-06 10:47:10


On Fri, Mar 6, 2009 at 10:04, Hansi <hansipet_at_[hidden]> wrote:
>
> I have a question. I need a lexical_cast for a BYTE. Now I get allways a
> compile error with VS2005 and VS2008:
>
> e.g.
>
>        unsigned char test = 2;
>
>        test = boost::lexical_cast<unsigned char>(L"2");
>
> Error   2       error C2679: binary '>>' : no operator found which takes a
> right-hand operand of type 'unsigned char' (or there is no acceptable
> conversion)     D:\boost\boost_1_38_0\boost\lexical_cast.hpp    771
>
> What I do wrong? How I can solve this problem?
>

You want to get '\002', not '2', right? If so, then it sounds like
you want the same solution as for the first problem in the FAQ:
http://www.boost.org/doc/libs/1_38_0/libs/conversion/lexical_cast.htm#faq


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