CppCon 2024 Modern C++ Error Handling -- Phil Nash
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!
Modern C++ Error Handling
by Phil Nash
Summary of the talk:
We’ve had exceptions in C++ since before the first standard. C++17 introduced std::optional and C++23 std::expected (along with the so-called Monadic Operations for both types).
What should we use and when?
Meanwhile we still have older approaches, such as boolean or error code returns, as well as global or thread local error status or pointer or reference arguments.
Do these still have a place?
And where does assert fit in? And the (hopefully) upcoming contracts?
Perhaps more importantly, once we’ve examined all the trade-offs, can we defer any of those decisions to when we are best positioned to commit to them?
Erroneous conditions can have a big impact on your code’s safety and security, so error handling shouldn’t just be left to the “exercise left for the reader” in the books we used to read. Let’s get this all straight.

A unique milestone: “Whole new language”
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
Templates are one of C++’s most powerful features, enabling developers to write generic, reusable code—but they come with a cost: notoriously verbose and opaque error messages. With the introduction of concepts in C++20, we can now impose clear constraints on template parameters and get far more helpful diagnostics when something goes wrong.
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
C++’s One Definition Rule (ODR) can cause subtle and hard-to-detect issues when compile-time switches lead to inconsistent definitions across translation units. However, by using type aliases and template instantiation, we can sidestep these violations—giving each module its own definition without triggering undefined behavior.
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held