CppCon 2018 has ended
Back To Schedule
Wednesday, September 26 • 09:00 - 10:00
Sane and Safe C++ Classes

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

C++ is a complex language and with the introduction of move semantics, noexcept and constexpr in C++11 and later, defining or declaring the right combination of magic keywords in the right place is daunting for the uninitiated. The talk will provide guidelines for how to circumvent expert territory and if needed, how to step there without shooting yourself in the foot or tripping a mine.

Many C++ guidelines try to limit the use of language features so that resulting code has higher chances to be correct and safe. This talk will give an overview of the kind of classes you can create in such a controlled setting and provides a map to where is expert territory that requires deliberate care about your classes.

For example, there is the Rule of Zero telling that you should let the compiler figure out what to provide. It carries far for the application level programmer, but still might not be sufficient. Should you then rely on the Rule of Five or Six? What would be the consequences? When should you actually deviate from the Rule of Zero and how?

Another area are classes representing values. Value classes better not have virtual member functions. But should you use final or not? Do you really need class hierarchies?

You will learn what kinds of classes are safe to design and how to spell their special member functions.

avatar for Peter Sommerlad

Peter Sommerlad

founder, Better Software: Consulting, Training, Reviews
Peter Sommerlad was director of IFS Institute for Software at FHO/HSR Rapperswil, Switzerland. Peter is co-author of the books POSA Vol.1 and Security Patterns and contributed to "97 things every programmer should know". His goal is to make software simpler and safer by Decremental... Read More →

Wednesday September 26, 2018 09:00 - 10:00 PDT
Breckenridge Hall (1st Floor)