Generalized fold expressions
summary
Demonstrates using C++17 fold expressions to process parameter packs and shows a comma-operator foreach trick that’s terse but cannot capture heterogeneous return types. Cites a Stack Overflow one‑liner that accumulates results via a callable used as a binary operator, then points out failure when intermediate types differ (for example concatenating multiple std::tuple types). Presents a hand‑rolled alternative that compiles and passes quick tests — implemented and working in the provided slides and repo.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:28Generalized fold expressions
- 1:17With comma operator
- 1:52Generalized fold one-liner
- 2:55Works with constexpr too
- 3:27Possible solution
related talks
05mBeautiful Folds
53mC++ Variadic Templates and Parameter Packs
01h 03mHigher order functions for ordinary C++ developers
32m`for_each_argument` explained and expanded
43m“Variadic expansion in examples"
01h 35mC++20 – My Favourite Code Examples
55mTemplates Made Easy With C++20
51mModern techniques for keeping your code dry
