I have a lambda function with a move capture that I want to pass to another function.
void DoSomething(std::function<void()> && func) {
//do something with the function
}
auto ptr = std::make_unique<object>();
auto func = [ptr = std::move(ptr)](){
// do something
};
DoSomething(std::move(func)); // compiler error
This causes a compiler error because std::function tries to access the copy constructor which is deleted by the capture of the unique_ptr. Any better way of accomplishing this?