Can the Regex code be placed into a class?
The following sample program comes with the Boost Regex distribution. It compiles and runs fine. Its purpose is to count the number of classes in the input text file. http://patriot.net/~ramon/regex_iterator_example.cpp.txt I am having a real hard time trying to convert the code to a class (named "Pairs"). The compilation problem occurs in this statement: std::for_each(m1, m2, ®ex_callback); The compiler suggests to use this statement, which does not compile either: std::for_each(m1, m2, &Pairs::regex_callback); Thanks, -Ramon http://www.parashift.com/c++-faq-lite/pointers-to-members.html
The following sample program comes with the Boost Regex distribution. It compiles and runs fine. Its purpose is to count the number of classes in the input text file.
http://patriot.net/~ramon/regex_iterator_example.cpp.txt
I am having a real hard time trying to convert the code to a class (named "Pairs").
The compilation problem occurs in this statement:
std::for_each(m1, m2, ®ex_callback);
The compiler suggests to use this statement, which does not compile either:
std::for_each(m1, m2, &Pairs::regex_callback);
Is regex_callback a member function? If so you will need to "bind" it to an object instance (using std::bind1st and std::mem_fun for example, see also regex_grep_example_3.cpp). HTH, John.
participants (2)
-
John Maddock
-
Ramon F Herrera