I lately tried to do something like this:
auto x = std::make_unique<int>(1);
auto l = [y = std::move(x)]() { return *y; };
std::function<void()> f(std::move(l)); //error, requires copy construction
And to my huge disappointment and confusion it threw a bunch of error messages in my face. As you already know, std::function
disallows construction from types that are not copy-constructible. Is there a specific reason why is it so? Or is it an overlook in the standard? What problems would construction from move-only types impose?