
16 Apr
2007
16 Apr
'07
3:09 p.m.
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