pass task functor by copy to avoid dangling pointers

master
Francisco Paisana 5 years ago
parent b2d3c2a150
commit 6746c5dfa5

@ -240,10 +240,10 @@ public:
{ {
} }
template <typename Func> template <typename Func>
moveable_task_t(Func&& f, Capture&& c) : moveable_task_t(Func&& f, Capture&& c) : capture(std::forward<Capture>(c))
func([this, f]() { f(std::move(capture)); }),
capture(std::forward<Capture>(c))
{ {
std::function<void(Capture)> ftmp{std::forward<Func>(f)};
func = [this, ftmp]() { ftmp(std::move(capture)); };
} }
void operator()() { func(); } void operator()() { func(); }

Loading…
Cancel
Save