`for_each_argument` explained and expanded
summary
Explains how Sean Parent’s one-line trick expands a parameter pack via an initializer_list-based comma trick to call a callable for each argument, then builds concrete utilities: for_each_argument with guaranteed left-to-right evaluation, a make_vector that uses std::common_type and reserves size, tuple iteration via std::index_sequence and std::apply, and a grouped-arity for_n that batches arguments by R. Code compiles, uses static_assert tests, prints the shown outputs, and C++17 fold expressions replace much of the boilerplate.
AI-written summary · about
chapters (10)
- 0:00Introduction and motivation
- 1:04Original for_each_argument explained
- 4:19Creating makeVector function
- 7:27Compile-time integer sequences
- 9:38Iterating over std::tuple elements
- 13:28Generalizing for_n_arys
- 20:31Implementing make_unordered_map
- 26:37C++17 fold expressions overview
- 29:29Modernizing for_n_arys with folds
- 31:40Q&A and closing
related talks
04mGeneralized fold expressions
43m“Variadic expansion in examples"
04mPutting `integer_sequence` on a diet
20mParameter Packs or How Swift Decided to Become C++
05mC++20 Lambdas: Familiar Template Syntax
06mReasoning with function signatures
01h 47mFunctional C++
55mCustom Overload Sets and Inline SFINAE for Truly Generic Interfaces
