C++: λ Demystified
summary
Lambda implementation is shown as compiler-generated closure classes using C++ Insights, revealing that captures become members and call operator(s) and that reordering captures can shrink a closure from 12→8 bytes on x86-64. Examples expose traps: returning a reference-capturing lambda causes dangling references, copying members captures the this pointer (prints 4 then 5 unless dereferenced), and unused copy-captures still force allocation causing three unused-variable warnings; also five syntactic places allow lambdas to appear.
AI-written summary · about
chapters (12)
- 0:00Start
- 2:58The Evolution of Lambdas
- 5:34Trailing Return Type
- 7:23Lambdas Internals
- 9:04Call Operator
- 17:32Conversion Operator
- 22:44Generic Lambdas
- 25:29The Dangling Reference Trap
- 38:46An Unused Variable Warning
- 41:47C + + 17
- 43:48Apply Lambdas
- 45:57Immediately Invoked Function Expressions
related talks
01h 26mLet's Look at Lambdas
01h 04mC++ Lambda Idioms
56mC++ Lambda Idioms
01h 00mA Kaleidoscope of C++ Lambdas
52mBack to Basics: Lambdas from Scratch
01h 01mC++ Insights: How stuff works, Lambdas and more!
05mLightning Talk: Into the Lambdaverse - Weird C++ Lambda Shenanigans
04mFunction Extraction with Lambda Expressions
