Why You Should Write Code That You Should Never Write
summary
A collection of short C++ snippets gets dissected: one shows right fold over assignment to iterate parameter packs backwards (using fold expressions and evaluation order subtleties), another uses an immediately‑invoked lambda in a static local guarded by cxa_guard_acquire to run code exactly once across threads (and even throw to run N−1 times); demos use Compiler Explorer and assembly, point out std::call_once/std::mutex as production alternatives, note C++20 CTAD fixes and std::make_index_sequence tricks for indexing packs, with some tweets >30,000 views.
AI-written summary · about
chapters (7)
- 0:00Introduction
- 0:34The first trick: back-folding
- 5:22Deep dive into fold evaluation
- 17:21Static local initialization
- 31:28Deduction guides for aggregates
- 40:38Parameter pack manipulation
- 59:12Q&A session








