3 ms·
> it does not move the local variable it references onto the heap C++ doesn't do such thing automatically, but there's nothing preventing you to do it yourself
by kccqzy 8y ago
> it does not move the local variable it references onto the heap
C++ doesn't do such thing automatically, but there's nothing preventing you to do it yourself. If you intend to use a local variable whose lifetime would not normally outlast the closure, feel free to use std::move and a move constructor. In general C++ gives you the tools to manage memory manually or semi-automatically, but not totally automatically. And it also doesn't, unlike Rust, force you to use memory correctly.