Classes C++23 style

Speaker: Sebastian Theophil

Audience level: [ Beginner | Intermediate | Advanced ]

Classes are maybe the most important language-feature of C++. It was originally called "C with classes" after all! Classes in C++ have constructors, destructors, base classes, template arguments, attributes etc. But that is just syntax. When we write and read code, a class should have meaning! It represents a value, a container, a resource or a state machine. Starting from these different use cases, I will show the best C++23 practices to define common types of classes. How do we define and constrain the life-cycle of an object? What special member functions should a class define or not define? What are regular types? What are standard layout types? I will cover the spaceship operator, conditionally explicit conversions, C++26 contracts, reference-qualified member functions and deducing this. By starting from common use-cases, I hope to show not only how to use these C++ features but when to use them.