Boost logo

Boost Users :

From: Terje Slettebų (tslettebo_at_[hidden])
Date: 2003-03-28 20:58:48


>From: "Black Ice" <yg-boost-users_at_[hidden]>

> When lexical_cast used under VC, and the option "Treat wchar_t as Build-in
> Type" is off
> The following code will cause compile error:
> int main(int argc, char * argv[])
> {
> string str("10");
> unsigned short n = lexical_cast<unsigned short>(str);
> return 0;
> }
>
> Because in lexical_cast::detail::widest_char, treat unsigned short as
> wchar_t!!

I have tested it, and can confirm this problem. The problem is that
lexical_cast doesn't disable wide character support in this case. It seems
it needs to test for BOOST_NO_INTRINSIC_WCHAR_T, after all, as it did
earlier. In other words, change this:

#if defined(BOOST_NO_STRINGSTREAM) || \
defined(BOOST_NO_STD_WSTRING) || \
defined(BOOST_NO_STD_LOCALE) || \
defined(BOOST_NO_CWCHAR) || \
defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
#define DISABLE_WIDE_CHAR_SUPPORT
#endif

to this:

#if defined(BOOST_NO_STRINGSTREAM) || \
defined(BOOST_NO_STD_WSTRING) || \
defined(BOOST_NO_STD_LOCALE) || \
defined(BOOST_NO_INTRINSIC_WCHAR_T)
#define DISABLE_WIDE_CHAR_SUPPORT
#endif

and remove this:

#ifdef BOOST_NO_INTRINSIC_WCHAR_T
#include <cwchar>
#endif

If this is done, it works, both for the option on or off.

This also disables wide character support on Intel C++, even though it
handles it, as it doesn't set _NATIVE_WCHAR_T_DEFINED, even when intrinsic
wchar_t is turned on. However, this is really an issue in the detection on
Intel C++, rather than with lexical_cast.

Regards,

Terje


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