While reading through the doc: https://isocpp.org/wiki/faq/cpp14-language#lambda-captures,
auto u = make_unique<some_type>( some, parameters ); // a unique_ptr is move-only
go.run( [ u=move(u) ] { do_something_with( u ); } ); // move the unique_ptr into the lambda
When we pass u
in do_something_with()
, shall we use std::move(u)
? I meant do_something_with(std::move(u))
given u
is still move-only as unique_ptr though its captured in lambda.
Thanks for the help!
Note: I came across this: https://stackoverflow.com/a/16968463/13097437 but it simply quotes the example which I think its buggy above.