2 ms·
You can write your own std::function, too, nor is it the only STL type that can take a capturing lambda (std::packaged_task for example). A capturing lambda is
by kllrnohj 6y ago
You can write your own std::function, too, nor is it the only STL type that can take a capturing lambda (std::packaged_task for example).
A capturing lambda is just a class with an operator(). It's complicated to do what std::function does, but fully possible.
In fact, custom std::function replacements have better lambda support than std::function itself. Such as unique_function in https://github.com/Naios/function2 https://github.com/Naios/function2 which can handle non-copyable lambdas.