On Saturday, July 29, 2006 at 22:40:31 (+1200) John Grabner writes:
I used to be able to write this :
void LineTracker::Analyse(const std::string &Buffer) { std::string::const_iterator start, end; start = Buffer.begin(); end = Buffer.end();
boost::regex_grep(std::bind1st(std::mem_fun(&LineTracker::grep_callback), this), start, end, expression); }
to get the regex to call back into my class. With the change to the new style using iterator I can do this.
void LineTracker::Analyse(const std::string &Buffer) { boost::sregex_iterator m1(Buffer.begin(), Buffer.end(), expression); boost::sregex_iterator m2; std::for_each(m1, m2, *this); }
However for_each makes a copy of my class, so at the end it does not update the current instance with the results.
What do I need to do to have the the current instance receive the call back from regex?
Use an inner class functor, pass the functor constructor an instance of your outer class when you call for_each: std::for_each(m1, m2, inner_functor(this)); Have inner_functor update your class as appropriate. Bill