
14 Jun
2010
14 Jun
'10
9:59 a.m.
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.