Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Each variable expressly named in the capture list is captured. The default capture will only capture variables that are both (a) not expressly named in the capture list and (b) <em>used</em> in the body of the lambda expression. If a variable is not expressly named and you don't use the variable in the lambda expression, then the variable is not captured. In your example, <code>my_huge_vector</code> is not captured.</p> <p>Per C++11 §5.1.2[expr.prim.lambda]/11:</p> <blockquote> <p>If a <em>lambda-expression</em> has an associated <em>capture-default</em> and its <em>compound-statement</em> <em>odr-uses</em> <code>this</code> or a variable with automatic storage duration and the <em>odr-used</em> entity is not explicitly captured, then the <em>odr-used</em> entity is said to be implicitly captured.</p> </blockquote> <p>Your lambda expression has an associated capture default: by default, you capture variables by value using the <code>[=]</code>. </p> <p>If and only if a variable is used (in the One Definition Rule sense of the term "used") is a variable implicitly captured. Since you don't use <code>my_huge_vector</code> at all in the body (the "compound statement") of the lambda expression, it is not implicitly captured.</p> <p>To continue with §5.1.2/14</p> <blockquote> <p>An entity is captured by copy if </p> <ul> <li>it is implicitly captured and the <em>capture-default</em> is <code>=</code> or if </li> <li>it is explicitly captured with a capture that does not include an <code>&amp;</code>. </li> </ul> </blockquote> <p>Since your <code>my_huge_vector</code> is not implicitly captured and it is not explicitly captured, it is not captured at all, by copy or by reference.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload