Boost logo

Boost Users :

Subject: [Boost-users] [Date Time] format_date_parser.parse_date fails to compile with "treat wchar_t as builtin type" set to No
From: Daniel Mitchell (DanielMitchell_at_[hidden])
Date: 2011-08-17 17:44:14


 Boost 1.47, using Visual Studio 2010 and Visual Studio 2008, with boost 1.47 both built myself from source and with boost from the boostpro installers. (and with boost 1.47 rebuilt myself with /Zwchar_t- in msvc.jam).

 If I set "treat wchar_t as builtin type" to "No", then the following code fails to compile:

#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

void parseDate()
{
    std::locale locale;
    boost::date_time::format_date_parser<boost::gregorian::date, wchar_t> parser(L"", locale);
    boost::date_time::special_values_parser<boost::gregorian::date, wchar_t> svp;

    boost::gregorian::date date = parser.parse_date(L"", L"", svp);
}
 

 It gives the following error:

c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(1116): error C2535: 'bool boost::detail::lexical_stream_limited_src<CharT,Base,Traits>::operator >>(unsigned short &)' : member function already defined or declared
          with
          [
              CharT=char_type,
              Base=base,
              Traits=traits
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(993) : see declaration of 'boost::detail::lexical_stream_limited_src<CharT,Base,Traits>::operator >>'
          with
          [
              CharT=char_type,
              Base=base,
              Traits=traits
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(1524) : see reference to class template instantiation 'boost::detail::lexical_stream_limited_src<CharT,Base,Traits>' being compiled
          with
          [
              CharT=char_type,
              Base=base,
              Traits=traits
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(1653) : see reference to function template instantiation 'Target boost::detail::lexical_cast<Target,src,false,char_type>(const std::basic_string<_Elem,_Traits,_Ax> &,CharT *,size_t)' being compiled
          with
          [
              Target=short,
              _Elem=wchar_t,
              _Traits=std::char_traits<wchar_t>,
              _Ax=std::allocator<wchar_t>,
              CharT=char_type
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(1641) : while compiling class template member function 'short boost::detail::lexical_cast_do_cast<Target,Source>::lexical_cast_impl(const Source &)'
          with
          [
              Target=short,
              Source=src
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\lexical_cast.hpp(1813) : see reference to class template instantiation 'boost::detail::lexical_cast_do_cast<Target,Source>' being compiled
          with
          [
              Target=short,
              Source=src
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\date_time\format_date_parser.hpp(72) : see reference to function template instantiation 'Target boost::lexical_cast<int_type,std::basic_string<_Elem,_Traits,_Ax>>(const Source &)' being compiled
          with
          [
              Target=short,
              int_type=short,
              _Elem=wchar_t,
              _Traits=std::char_traits<wchar_t>,
              _Ax=std::allocator<wchar_t>,
              Source=std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\date_time\format_date_parser.hpp(365) : see reference to function template instantiation 'int_type boost::date_time::fixed_string_to_int<short,charT>(std::istreambuf_iterator<_Elem,_Traits> &,std::istreambuf_iterator<_Elem,_Traits> &,boost::date_time::parse_match_result<charT> &,unsigned int,const charT &)' being compiled
          with
          [
              int_type=short,
              charT=wchar_t,
              _Elem=wchar_t,
              _Traits=std::char_traits<wchar_t>
          ]
          c:\users\danielm\downloads\boost_1_47_0\boost_1_47_0\boost\date_time\format_date_parser.hpp(254) : while compiling class template member function 'boost::gregorian::date boost::date_time::format_date_parser<date_type,charT>::parse_date(std::istreambuf_iterator<_Elem,_Traits> &,std::istreambuf_iterator<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Ax>,const boost::date_time::special_values_parser<date_type,charT> &) const'
          with
          [
              date_type=boost::gregorian::date,
              charT=wchar_t,
              _Elem=wchar_t,
              _Traits=std::char_traits<wchar_t>,
              _Ax=std::allocator<wchar_t>
          ]
          c:\source\dan\boost_wchar_t_test\boost_wchar_t_test\boost_wchar_t_test.cpp(18) : see reference to class template instantiation 'boost::date_time::format_date_parser<date_type,charT>' being compiled
          with
          [
              date_type=boost::gregorian::date,
              charT=wchar_t
          ]

 If I set "wchar_t is builtin type" to Yes, then it compiles fine.

 Testing with #pragma message to verify things, BOOST_NO_INTRINSIC_WCHAR_T is defined (or not defined) appropriately depending on how I set that compiler option, so it looks as if Boost knows what's going on at that level.
 
 I've tried all the possible reconfigurations I can think of, but this error happens with the boostpro installs, with Boost built unchanged from the 1.47 distribution, and with Boost rebuilt with /Zwchar_t- set in msvc.jam.

 Is there a way to solve this? The issue originally appears when trying to build code from another library -- but this is a minimal repro it with just boost code, so I think it's a Boost problem, unless I'm missing something.

 thanks,

 -- dan


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