
Hi! strange code... You are trying to convert a 2 byte character string into a single byte unsigned character value? Std C++ does not definitely provide possibility for it. But if you know how to do the conversion, overload the operator >>, which accepsts the istream and unsigned char, smth. similar to: namespace your_namespace //define it in your namespace, but so that ADL finds it { std::istream& operator>>(std::istream& is, unsigned char& ch) { // read needed ammount of bytes from is (actually 1) ch=// convert it and assign to ch... return is; } } Try using wchar_t instead of unsigned char. Regards, Ovanes On Fri, Mar 6, 2009 at 4:04 PM, Hansi <hansipet@web.de> wrote:
Hello,
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?
Regards Hansjörg