I need object to be alive from some point in code, until some task starts executing. Like in example:
shared_ptr<FromThisPointToTaskStart> ftptts = make_shared<FromThisPointToTaskStart>();
. . .
runningTask.then([ftptts](task<void> task)
{
. . .
try{
// Decrementing reference and deallocating object if ref count == 0;
ftptts = nullptr;
task.get();
}
}
// decrementing reference count so that it lives untill task starts
ftptts = nullptr;
The problem is that capture list catches this as constant and I cannot change it. What is the right way to do what I want? Should I pass it like [&ftptts] ?
Thanks!