[Boost-bugs] [Boost C++ Libraries] #4496: xpressive::as<int>(_) does not work with wchar_t

Subject: [Boost-bugs] [Boost C++ Libraries] #4496: xpressive::as<int>(_) does not work with wchar_t
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-30 14:02:14


#4496: xpressive::as<int>(_) does not work with wchar_t
-------------------------------------+--------------------------------------
 Reporter: anonymous | Owner: eric_niebler
     Type: Bugs | Status: new
Milestone: Boost 1.44.0 | Component: xpressive
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: xpressive regex_actions |
-------------------------------------+--------------------------------------
 {{{
   using namespace boost::xpressive;

   std::wstring version(L"0.9.500");

   int maj1(0), min1(0), build1(0);

   wsregex re1 = (+_d)[ref(maj1) = as<int>(_)] >> L"." >>
                 (+_d)[ref(min1) = as<int>(_)] >> L"." >>
                 (+_d)[ref(build1) = as<int>(_)];

   bool v1 = regex_match(version, re1);

   std::wcout << maj1 << std::endl; // 48 must be 0
   std::wcout << min1 << std::endl; // 57 must be 9
   std::wcout << build1 << std::endl; // 534848 must be 500
 }}}

 The cause is


 {{{
         template<typename T>
         struct as
         {
             typedef T result_type;

             template<typename Value>
             T operator()(Value const &val) const
             {
                 return lexical_cast<T>(val);
             }
         };
 }}}

 val is sub_match type (this case)

 lexical_cast<T> uses stream_char<T> to define the widest char
 while there is no spec for stream_char<xpressive::sub_match>
 so lexical_cast uses char as char_type

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4496>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC