The fact that lambda is implemented as a class is not really a programmer's problem. You do not need to know / care / think about it. By extension, whether it has a default constructor or why it does / does not, is not related to everyday life.
As it happens, it does not currently execute:
[C++14: expr.prim.lambda/20]: The closure type associated with the lambda expression has a remote (8.4.3) default constructor and a remote copy assignment statement. It has an implicitly declared copy constructor (12.8) and may have an implicitly declared move constructor (12.8). [..]
[C++17: expr.prim.lambda/11]: The closure type associated with the lambda expression does not have a default constructor and remote copy assignment operator. It has a default copy constructor and a default move constructor. [..]
But! This will be a change in C ++ 20 , as described in P0624r2 . As far as I can tell, your code will become valid in accordance with this standard ( until you add any bindings to it ).
But for now, if you want to store functions, use std::function :
#include <iostream>
Disclaimer: This is a contrived example. In the above code you do not take the overhead std::function ; you would just do auto lam = ... , as in the source code, and that would be so. But the OP for some reason showed the need to copy it into a new, default built object. Here is what I show how to do it.
source share