Recently I read a little about lambda expressions on the Internet, and it seems to me that in C ++ 0x lambda expressions there will not be any type (or types) that will be associated exclusively with lambda expressions - in other words, lambda expressions will match the template arguments or auto arguments / variables. What happens as described here is that
Compilers that support lambdas will create a unique anonymous functor type for each lambda expression
My question is, is this bad? It makes no sense to have some kind of keyword that matches only lambda expressions, for example. lambda which will work as follows
void f(std::function<int(int)> func) { func(2); } template<typename T> void g(T func) { func(2); } void h(lambda func) { func(2); } int main() { int fpointer(int); struct { int operator()(int var) { return var; } } functor; f(fpointer);
Honestly, I really don't see the usefulness of this (especially considering that auto accepts lambda expressions, so then you could assign a lambda to a variable), but it still doesnβt sit right with me that lambda expressions are anonymous types and cannot be associated specifically with only one specific type (with the exception of all others).
In essence, my question is whether it is good that lambda expressions are anonymous (both in terms of utility), and the lack of a lambda type robs us of any functionality - and philosophically - does this really make lambda expressions always have "type" auto )?
c ++ lambda c ++ 11
GRB
source share