|
Boost : |
Subject: Re: [boost] [GSoC][Phoenix3] Regarding mutability of arguments passed to phoenix expressions
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-06-14 05:59:45
Eric Niebler wrote:
> On 6/12/2010 5:34 PM, Mathias Gaunard wrote:
>> For captures, I don't see how anyone would want to do anything but
>> capture everything by reference.
>>
>
> function<int(int)> plus_i( int i )
> {
> return _1 + i;
> }
>
> If you capture i by reference, this code will compile but crash at
> runtime. Have fun debugging it! :-)
My main use for lambdas (be them C++0x or DSEL ones) is to pass them
directly to a higher-order function or an iterator adapter; I never
store them past their lifetime.
I'm not sure lambdas in callbacks or signals scenarios is where they
really shine.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk