Boost logo

Boost Users :

From: shunsuke (pstade.mb_at_[hidden])
Date: 2007-04-16 11:09:55


Graham Reitz wrote:

> int main()
> {
> boost::regex("(\\d+),?");
> string s = "1,1,2,3,5,8,13,21";
>
> boost::sregex_iterator it(s.begin(), s.end(), reg);
> // Is end initialized to anything here?
> boost::sregex_iterator end;
>
> regex_callback c;
>
> // How is end valid here?
> int sum = for_each(it, end, c).sum();
>
> return 0;
> }

Your code seems to work fine.
('reg' isn't defined, though :-)
You want to know how to work?
'it' automagically turns into the value that equals to 'end' when 'it'
reaches to 's.end()'.
Thus everything works fine.
You can look into <boost/regex/v4/regex_iterator.hpp> in detail.

Regards,

-- 
Shunsuke Sogame

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