And Then() Some(T) Functional Adventures With C++23 std::optional and std::expected
summary
Argues that C++23’s std::optional plus std::expected and continuation helpers let code become functional by lifting functions and composing pipelines rather than unwrapping at each step. Shows concrete patterns: implements fmap for optional and vector, composes parsing and clamping via and_then continuations, and models a multi-step widget construction pipeline that returns optional values. Notes nested-option pitfalls and recommends std::expected to carry error context. Uses C++23, compiler stdlib support (gcc/clang/msvc) and working example code from slides.
AI-written summary · about
chapters (11)
- 0:00Introduction to functional thinking
- 3:17Functional programming basics
- 11:25Lifting and higher-order functions
- 16:48Boxes and optional values
- 28:59Type constructors and composition
- 35:24Monads and chaining operations
- 42:55Expected for error handling
- 48:16C++23 standard support
- 52:10Retrofitting functional style
- 55:28Ranges and functional style
- 56:11Conclusion and readability
related talks
20mAnd Then() Some(T): C++ Combinators - Higher-Order Functions in Cpp
01h 03mHigher order functions for ordinary C++ developers
01h 47mFunctional C++
01h 31mFunctional Programming in Modern C++: The Imperatives Must Go!
38mWhat's New In C++23
01h 03m“What Could Possibly Go Wrong?: A Tale of Expectations and Exceptions”
29m“Functional programming: functors and monads"
01h 18mSafe and Readable C++ Code: Monadic Operations in C++23
