Overview
Explore a comprehensive conference talk on eliminating null pointers in C++ programming. Learn how banning null can lead to beautiful, safer code with clearer interfaces and fewer unnecessary checks. Discover techniques for replacing null with non-nullable types, std::optional, and gsl::not_null. Understand the problems associated with null pointers, including undefined behavior and unclear APIs. Dive into practical examples of using value semantics, references, and standard library components to create more robust C++ code. Gain insights on bug classification and strategies for handling both optional and definite pointers. Suitable for introductory-level C++ developers looking to improve code safety and readability.
Syllabus
Intro
Outline
Optional parameter
Late initialisation of member
Dereferencing is undefined behaviour
Unclear APIs
Why is static typing good?
What does null do to static typing?
Conflating notions
Values which can be missing
Techniques which allow for missing values
References over pointers
Values over pointers
Return values
Use the standard library
Maybe techniques are for maybe values
std::optional
Bug classification Where
Remaining pointers
Tackle maybe pointers
Tackle definite pointers
A bright future
Taught by
NDC Conferences