Usually, a C++ lambda without a capture should be convertable to a c-style function pointer. Somehow, converting it using std::function::target
does not work (i
In your first call, std::function
does not bother with decaying the lambda into a pointer, it just stores it, with its actual type (which is indeed not void()
).
You can force the lambda to decay into a pointer before constructing the std::function
with the latter by simply using a unary +
:
callMe(+[](){});
// ^