intvalue=get_value();std::shared_ptr<Foo>sharedFoo=get_foo();constautolambda=[value,sharedFoo]()->task<void>co_awaitsomething();// "sharedFoo" and "value" have already been destroyed
// the "shared" pointer didn't accomplish anything
lambda();}// the lambda closure object has now gone out of scope
task<void>Class::do_something(intvalue,std::shared_ptr<Foo>sharedFoo)co_awaitsomething();// sharedFoo and value are still valid at this point
voidSomeOtherFunction()intvalue=get_value();std::shared_ptr<Foo>sharedFoo=get_foo();do_something(value,sharedFoo);