Monadic Operations in C++23
summary
Concrete examples show how C++20/23 turns nested loops and error flags into composable pipelines using std::views::transform and std::views::join, and how error handling swaps to std::optional or std::expected to carry failures. Live pitfalls include dangling references from lazy views, overload-resolution gotchas solved with lambdas, and when to return containers vs views. Benchmarks across compilers expose variable performance tradeoffs; slides and a compiler error cheat sheet on GitHub provide reproducible code and fixes.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 3:14Talk goals
- 4:36Functors: transforming values
- 8:25Functors rules
- 10:09Ranges views as functors
- 14:03Ranges views pitfalls
- 15:48Functors with callables
- 19:01Monads: unwrapping structures
- 22:33Monadic pipelines vs loops
- 24:36Pure functions and safety
- 29:11Error handling with optional
- 37:21Error reporting with expected
- 40:08Monadic style with optional
- 42:33Monads limitations
- 43:16Debugging monad errors
- 45:44Debugging monadic pipelines
- 46:25Performance of monadic code
- 47:30Advantages and disadvantages of monads
- 48:15Further resources
- 49:20Recap of patterns
- 51:25Q&A
related talks
01h 02mC++20 - My Favorite Code Examples
50mThinking Functionally in C++
56mWhat’s New in C++23
01h 02mFunctional Composable Operations with Unix-Style Pipes in C++
58mThe Imperatives Must Go! [Functional Programming in Modern C++]
01h 23mC++23 Standard Library Preview
54mC++26: an overview
42mAwaiting for the ranges: C++17
