
Robert Dailey wrote:
On Sun, Mar 16, 2008 at 5:44 PM, Eric Niebler <eric@boost-consulting.com> wrote:
I've made a small addition ... the formatter can be a lambda, too, if you #include <boost/xpressive/regex_actions.hpp>. The above can now be written simply as:
using xpressive::ref; string output = regex_replace(input, rx, ref(replacements)[_]);
Here, "_" gets substituted with a sub_match representing the current match. You can also use s1, s2, etc., to access the other sub-matches.
How is "[_]" legal C++ syntax? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
"_" is just an identifier, so "[_]" is calling the [] operator with the parameter being whatever "_" refers to. In this case, it allows for the creation of lambda expressions. Sean