Generalised capture In C++11, lambdas can only capture existing objects in their scope: int z = 42; auto myLambda = [z](int x){ std::cout Am I the only one who doesn't see much of a difference here?
std::function make_func(std::unique_ptr ptr) {
return [p = std::move(ptr)]() { return *p; }
}
Without generalized capture syntax, there's no good way to transfer ownership into the closure (a regular `[ptr]` capture would attempt to make a copy, and a by-ref `[&ptr]` capture would lead to a use-after-free).