Lightning Talk: Into the Lambdaverse - Weird C++ Lambda Shenanigans
summary
Explains why modifying a captured variable sometimes fails: lambda's operator() is const unless mutable is used, but init-captures introduce an implicit auto variable whose deduced type (and constness) determines the captured member, so a const original can yield a const capture. Shows the surprising fix of writing n = n to force a mutable copy, cites post-C++23 rule changes about parentheses, and traces behavior back to the standard's wording about no extra copy.
AI-written summary · about
chapters (4)
related talks
01h 00mA Kaleidoscope of C++ Lambdas
01h 00mC++: λ Demystified
52mBack to Basics: Lambdas from Scratch
01h 26mLet's Look at Lambdas
01h 04mC++ Lambda Idioms
56mC++ Lambda Idioms
05mImmediately Invoked Coroutine Lambdas in C++23 - Lifetime Pitfalls & Best Practices
32mCute C++ Tricks, Part 2 of N: More code you should learn from and never write
