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 for other things
you can do with lambda expressions in xpressive 2.0 (which *will* be
part of 1.35).

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at