[Boost-bugs] [Boost C++ Libraries] #4837: referencing subexpr matches via names asserts

Subject: [Boost-bugs] [Boost C++ Libraries] #4837: referencing subexpr matches via names asserts
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-10 21:23:34


#4837: referencing subexpr matches via names asserts
---------------------------------------+------------------------------------
 Reporter: nis.aggarwal@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: regex
  Version: Boost 1.40.0 | Severity: Showstopper
 Keywords: regex named subexpression |
---------------------------------------+------------------------------------
 I am using named subexpressions. The regex pattern constructs fine and the
 matching works fine too but when I try to index into the match_results
 object using the name, an assertion is thrown.

 {{{
 #include <boost/regex.hpp>
 #include <string>
 #include <iostream>
 #include <stdio.h>

 using namespace boost;

 int main()
 {
     std::string str = "for is while";

     regex pat("(?<keyword>\\b(for|while)\\b)");
     sregex_iterator match_iter(str.begin(), str.end(), pat);
     sregex_iterator match_end;

     for (; match_iter != match_end; ++match_iter) {
         smatch match = (*match_iter);

         ssub_match keywordMatch = match["keyword"];
         if (keywordMatch.matched) {
             printf("matched a keyword!\n");
         }
         size_t pos = (*match_iter).position((size_t)0);
         size_t len = (*match_iter)[0].second - (*match_iter)[0].first;

         std::cout << pos << "," << len << std::endl;
     }

     return 0;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4837>
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