r/programming • • Apr 01 '13

Ten C++11 Features Every C++ Developer Should Use

http://www.codeproject.com/Articles/570638/Ten-Cplusplus11-Features-Every-Cplusplus-Developer
469 Upvotes

283 comments sorted by

View all comments

Show parent comments

2

u/snk_kid Apr 02 '13 edited Apr 02 '13

I think he/she is referring to the fact that lambda expressions in C++11 can not be recursively defined, this is not possible:

auto fib = &fib {return n < 2 ? 1 : fib (n-1) + fib (n-2)};

So you have to use a library abstraction like std::function to achieve this, also by default this uses heap-allocation unless you provide a customer allocator in the second parameter of std::function, a pure lambda expression assigned to a type-infered name (auto x = {...};) is stack allocated.

1

u/TheDeputy Apr 04 '13

Awesome. Thanks for the clarification!