Doing this today I'd just have a std::function parameter and have callers pass in a lambda. I may use a third party std::function that doesn't have the weird copy semantics though
Doing this today I'd just have a std::function parameter and have callers pass in a lambda. I may use a third party std::function that doesn't have the weird copy semantics though
> I may use a third party std::function that doesn't have the weird copy semantics though
Note that C++23 brings std::move_only_function if you're storing a callback for later use, as well as std::function_ref if you don't need lifetime extension.
https://en.cppreference.com/w/cpp/utility/functional/move_on...
This paper is about the idea that eventually became std::function.