Boost logo

Boost Users :

From: Jochen Hammann (jochen.hammann_at_[hidden])
Date: 2004-12-10 06:17:36


Hello,

I have tried to compile the following code with the Microsoft
Visual C++ 7.1 compiler.

#include <boost/lexical_cast.hpp>

int main(int argc, char** argv)
{
    using namespace std;
    using namespace boost;

    wstring wstrFoo = boost::lexical_cast<wstring>( 200 );

    return 0;
}

If I compile this example with native wchar_t support (/Zc:wchar_t)
everything works fine. Otherwise, if I compile the example without
native wchar_t compiler support, I encounter the following compiler
error:

d:\Temp\Boost\boost\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)
         d:\Temp\Boost\boost\lexical_cast.hpp(189) : see reference to function template instantiation 'bool boost::detail::lexical_stream<Target,Source>::operator >><Target>(InputStreamable &)' being
compiled
         with
         [
             Target=std::wstring,
             Source=int,
             InputStreamable=std::wstring
         ]
         d:\Temp\BoostConsole\BoostConsole.cpp(12) : see reference to function template instantiation 'Target boost::lexical_cast<std::wstring,int>(Source)' being compiled
         with
         [
             Target=std::wstring,
             Source=int
         ]

As I can see in the header file "lexical_cast.hpp" the macro BOOST_NO_INTRINSIC_WCHAR_T
is defined, if the compiler option /Zc:wchar_t is not specified. This causes the macro
DISABLE_WIDE_CHAR_SUPPORT to be defined as well and thus the lexical_stream::operator(std::wstring)
will not be compiled.

Do anyone know a workaround, so that I can use lexical_cast without native wchar_t
compiler support and wstring?

Is it really necessary to define DISABLE_WIDE_CHAR_SUPPORT, if BOOST_NO_INTRINSIC_WCHAR_T
is defined only? For testing purposes I have commented out the two
#ifndef DISABLE_WIDE_CHAR_SUPPORT statement. Now, I could compile the example without
native wchar_t support. But I think, that this results in side effects, which I'm not able
to see.

Regards,

     Jochen.


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