[EMCpp]Item-32 Use Init Capture to Move Objects Into Closures
· ☕ 3 min read
Use init capture to move objects into closures in C++14; emulate init capture via hand-written classes or std::bind
in C++11.
Use init capture to move objects into closures in C++14; emulate init capture via hand-written classes or std::bind
in C++11.
Default by-reference capture can lead to dangling references; default by-value capture is susceptible to dangling pointers, while misleadingly susggests the lambdas are self-contained.
Reference collapsing occurs in four contexts: template instantiation, auto type generation, creation and use of typedefs and alias declarations, and decltype.