Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-03-16 20:49:18


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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk