What type of variable does lambda contain

Can you explain what type Lin this context. In other words, what type can I use instead of the autokeyword?

int main(){
 int x=0;
 auto L = [x] (int y)->bool{
   return x>y;
 };
  return 0; 
}
+4
source share
2 answers

In C ++ 11, there is nothing that could be used instead autoin this context, which would mean the same type. This is because the type of each lambda expression is a unique, unnamed type. Citation C ++ 11 5.1.2 / 3:

The type of lambda expression (which is also the type of the closure object) is a unique unnamed improper class type - called the closure type - whose properties are described below ....

+6

std::function `auto, .

:

, ... . , - .

, std::, .

+1

All Articles