C++ 23 · Classes, memory and templates
Constrain a template with a concept
Accept only integral types and get clear error messages otherwise (C++20).
template <std::integral T>
T twice(T value) {
return value * 2;
}
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