This issue is addressed by lambda generalized capture in C++14:
// a unique_ptr is move-only
auto u = make_unique<some_type>(some, parameters);
// move the unique_ptr into the lambda
go.run([u = move(u)]{do_something_with(u);});
More Related Contents:
- What is a lambda expression in C++11?
- Is it possible to figure out the parameter type and return type of a lambda?
- C++11 does not deduce type when std::function or lambda functions are involved
- Recursive lambda functions in C++11
- What is the type of lambda when deduced with “auto” in C++11?
- Is there any use for unique_ptr with array?
- How to convert a lambda to an std::function using templates
- “Downcasting” unique_ptr to unique_ptr
- Copy constructor for a class with unique_ptr
- Resolving ambiguous overload on function pointer and std::function for a lambda using + (unary plus)
- Bind Vs Lambda?
- Capturing a reference by reference in a C++11 lambda
- Can lambda functions be templated?
- Inferring the call signature of a lambda or arbitrary callable for “make_function”
- I cannot pass lambda as std::function
- Lambda capture as const reference?
- Proper way to create unique_ptr that holds an allocated array
- std::unique_ptr, deleters and the Win32 API
- Lifetime of lambda objects in relation to function pointer conversion
- Why can’t I capture this by-reference (‘&this’) in lambda?
- std::auto_ptr to std::unique_ptr
- How does the custom deleter of std::unique_ptr work?
- std::remove_if – lambda, not removing anything from the collection
- error::make_unique is not a member of ‘std’
- Lambda functions as base classes
- shared_ptr is to weak_ptr as unique_ptr is to… what?
- What is the purpose of std::function and how to use it?
- In lambda functions syntax, what purpose does a ‘capture list’ serve?
- Is there a way to write make_unique() in VS2012?
- Lambdas and std::function