Consider the following code:
struct S { int x; void f() { auto l = [&](){ x = 42; }; //this is implicitly captured here } };
Section 5.1.2 / 14 states:
An entity is captured by the copy if it is implicitly committed, and the default is = or if it is explicitly captured with a capture that does not include &.
Therefore, I conclude that this not captured by the copy. But then in ยง 5.1.2 / 15:
An object is captured by reference if it is implicitly or explicitly captured, but not captured by the copy. It is not indicated whether declared additional elements of a non-static element are declared in the closure type for objects captured by the link.
this is fixed by reference. But now in ยง5.1.2 / 17 it says:
[...] If this fixed, each use of odr this converted to access the corresponding unnamed data element of the closure type, [...]
As far as I understand, this means that the closure type must have an unnamed data element corresponding to the this pointer. But since this is fixed by reference, the standard does not require such an element. What am I wrong about?
source share