reference capture

2 moment(s) that assert this concept — showing 1–2 of 2

single sourceRests on a single channel — treat as a lead, verify independently
↣ how this spread over time →
provenance — click a node to open its encoding unit
[1] CppCon[2] CppCon
showing 2 of 2 moments
CppCon · youtube · en
1Captured variables by reference result in private reference members initialized at the time of lambda definition, with unspecified order and number of members.
“when you capture by reference something very similar happens you get private members that are references notionally and again these references are going to be initialized with the values of the variables that you've captured at the point where you write the Lambda expression however here the standard says that the compiler has even more freedom it is actually unspecified whether it even adds any extra members if you capture by reference and how many of them there are”
spoken · 634s · 2022-11-10
CppCon · youtube · en
2The compiler may optimize reference captures by reusing pointers or using offsets to reduce memory usage.
“for example if you catch two variables by reference but you only ever use one at a time you use one and then later use the other uh it can reuse the same pointer or for example if the variables are close to each other it can instead of storing two pointers and can store one pointer and then use like an offset or something like this”
spoken · 671s · 2022-11-10