От: | jazzer | Skype: enerjazzer | |
Дата: | 21.12.12 02:14 | ||
Оценка: | 99 (13) |
The current version (12/2012) implements subproposals 2.1, 2.2, 2.3 and 2.5.
2.1 Allow the type-specifier within a parameter declaration of a lambda to be auto (i.e. auto is mandatory)
auto Sum = [](auto a, decltype(a) b) { return a + b; }; int i = Sum(3, 4); double d = Sum(3.14, 2.77);
2.2 Allow the use of familiar template syntax in lambda expressions
auto NumElements = []<int N>(auto (&a)[N]) { return N; }; int arri[]{1, 2, 3}; double arrd[]{3.14, 2.77, 6.626}; auto total = NumElements(arri) + NumElements(arrd);
2.3 Permit a lambda body to be an expression
int local = 10; auto L = [&](auto a) a + ++local;
2.5 Autogenerate a conversion to function pointer in captureless generic lambdas
auto L = [](auto a, decltype(a) b) { return a + b; }; int (*fp)(int, int) = L;
You will always get what you always got
If you always do what you always did