Five Issues with std::expected and How to Fix Them
summary
C++ std::expected currently allows value and error of the same type, mixes monadic and procedural APIs, lacks customization points for failed access, and misses convenient bind/applicative helpers; proposed fixes include restricting convertible types and using std::variant under the hood to simplify implementation, adding a customization point for value/error access, shipping built-in bind_back/front inside monadic operations to avoid extra captures, and offering an applicative apply/up and pipe-based unwrap for tests — a bespoke expected implementation with these features is already on GitHub and is used successfully in a context‑specific product.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:13Basic usage and monadic ops
- 6:50Under the hood of std::expected
- 12:32API duplication in monadic interfaces
- 17:48Missing error handling customization
- 23:34Bind back and bind front
- 31:09More monadic operations needed
- 39:20Future improvements and alternatives
- 43:59Q&A








