Expect the expected
summary
Proposal and prototype for a discriminated-union error type that unifies local error returns and centralized exceptions by storing either the result or an explanatory error value. Uses expected<T> built on std::variant/union plus a bool flag, an unexpected wrapper to disambiguate error constructors, and a value() accessor that throws on demand while operator* is UB. Covers copy/move, a fragile swap requiring many SFINAE constraints, allows collecting exceptions without throwing, and notes measurable call-overhead when exceptions are enabled.
AI-written summary · about
chapters (10)
- 0:00Unexpected St. Petersburg story
- 3:15Introducing Expected concept
- 13:11Designing error handling from scratch
- 20:39Problems with exceptions today
- 24:15Introducing std::expected
- 33:18Expected implementation details
- 41:55Swapping expected objects
- 47:16Typical usage examples
- 51:16Advantages of expected
- 52:01Q&A session
related talks
44mError handling in C++: as easy as "use exceptions"?
53mThe Dawn Of A New Error
44mThe Dawn of a New Error
45mTo Err is Human - Robust Error Handling in C++26
01h 29mC++ Error Handling
01h 04mKEYNOTE: De-fragmenting C++: Making exceptions more affordable and usable
57mAnd Then() Some(T) Functional Adventures With C++23 std::optional and std::expected
54mTypical C++, But Why?
