C++ 23 · Classes, memory and templates
Capture variables in a lambda
Capture by value with [=] or by reference with [&], or name what you need.
int factor = 3;
auto times = [factor](int n) { return n * factor; };
More classes, memory and templates commands
- Define a class
- Use polymorphism
- Own an object with unique_ptr
- Share ownership with shared_ptr
- Move instead of copy
- Lock a mutex safely
All classes, memory and templates commands · C++ 23 cheatsheet