Boost logo

Boost :

From: Darren Cook (darren_at_[hidden])
Date: 2004-03-16 02:52:40

I finally upgrade to boost 1.31; as I got compile errors around the
regex_grep stuff I decided to switch to regex_iterator.

1. It would be helpful if the top page of the docs had direct links to
explanations of smatch and similar classes.

2. An example of how to use sub_match would be useful. The C++ parser
example for regex_iterator is not ideal because: a) the regex is rather
complex; b) the callback just uses str(), and never shows the type to use if
you want to iterate through each character in the match.

3. I get this error (see P.S. for my code)
`iterator' is
    not a member of type `boost::sub_match<__gnu_cxx::__normal_iterator<const
    char*, std::basic_string<char, std::char_traits<char>, std::allocator<char>
> > >'

but this page says sub_match has an iterator type.

It compiles when I explicitly use std::string::const_iterator.


P.S. Cut down, my code looks like:

bool parse(const boost::smatch::value_type &crd,const std::string &status){
boost::smatch::value_type::iterator p=crd.first; // <-- won't compile
//std::string::const_iterator p=crd.first; // <-- compiles
while(p<crd.second){ ... }

//In class Functor:
bool operator()(const boost::match_results<std::string::const_iterator>& m){
bool ok=parse(m[1],m.str(2));

std::string comment; //The string to parse
boost::regex status_re("...");
Functor callback(...);

boost::sregex_iterator m1(comment.begin(), comment.end(), status_re);
boost::sregex_iterator m2;
if(m1==m2)return 0;
std::for_each(m1, m2, callback);

Boost list run by bdawes at, gregod at, cpdaniel at, john at