std::function allows you to store something if you provided the following for signature:
- all argument types are implicitly converted to the argument types of the stored called object and
- the return type of the stored called object is implicitly converted to the signature return type
std::nullptr_t implicitly converted to any type of pointer and gives the value of a null pointer of this type of pointer.
Note that your code is actually not valid C ++ 11, since in the second lambda you have not only return expr; , since such a conclusion will not be output. GCC (and Clang, IIRC) will implement this as an extension, as it will be part of the standard at some time.
source share