
17 Mar
2008
17 Mar
'08
12:49 a.m.
Robert Dailey wrote:
Eric Niebler wrote: 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?
It's magic. Actually, it's a lambda expression. xpressive::ref() creates a lazy reference, operator[] creates an object representing a lazy index operation, etc.. Check out http://tinyurl.com/36qfn6 for other things you can do with lambda expressions in xpressive 2.0 (which *will* be part of 1.35). -- Eric Niebler Boost Consulting www.boost-consulting.com