Modify

Ticket #4496 (closed Bugs: fixed)

Opened 4 years ago

Last modified 4 years ago

xpressive::as<int>(_) does not work with wchar_t

Reported by: anonymous Owned by: eric_niebler
Milestone: Boost 1.44.0 Component: xpressive
Version: Boost 1.44.0 Severity: Problem
Keywords: xpressive regex_actions Cc:

Description

  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

Attachments

Change History

comment:1 Changed 4 years ago by anonymous

MS VC2008

comment:2 Changed 4 years ago by eric_niebler

  • Status changed from new to assigned

comment:3 Changed 4 years ago by eric_niebler

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [65788]) as() handles wide sub_match objects correctly, fixes #4496

comment:4 Changed 4 years ago by eric_niebler

(In [65866]) Merged revisions 65788 via svnmerge from  https://svn.boost.org/svn/boost/trunk

........

r65788 | eric_niebler | 2010-10-06 12:02:04 -0700 (Wed, 06 Oct 2010) | 1 line

as() handles wide sub_match objects correctly, fixes #4496

........

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.