Boost logo

Boost :

From: Sean Hunt (rideau3_at_[hidden])
Date: 2008-03-16 22:30:48


Robert Dailey wrote:
> On Sun, Mar 16, 2008 at 5:44 PM, Eric Niebler <eric_at_[hidden]>
> 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


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