Title
capture-default in lambdas in local default arguments
Status
cd2
Section
7.5.6.3 [expr.prim.lambda.capture]
Submitter
Steve Adamczyk

Created on 2009-02-10.00:00:00 last changed 178 months ago

Messages

Date: 2009-07-15.00:00:00

[Voted into the WP at the July, 2009 meeting as part of N2927.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009)

See document PL22.16/09-0117 = WG21 N2927.

Date: 2009-02-10.00:00:00

Assuming that it is permitted to use a lambda as a default argument in a block-scope function declaration (see issue 754), it is presumably ill-formed for such a lambda expression to refer to a local automatic variable (9.3.4.7 [dcl.fct.default] paragraph 7). What does this mean for capture-defaults? For example,

    void f() {
      int i = 1;
      void f(int = ([i]() { return i; })());  // Definitely an error
      void g(int = ([i]() { return 0; })());  // Probably an error
      void h(int = ([=]() { return i; })());  // Definitely an error
      void o(int = ([=]() { return 0; })());  // Okay?
      void p(int = ([]() { return sizeof i; })());  // Presumably okay
    }
History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-11-08 00:00:00adminsetstatus: dr -> wp
2009-08-03 00:00:00adminsetmessages: + msg2247
2009-08-03 00:00:00adminsetstatus: review -> dr
2009-03-23 00:00:00adminsetmessages: + msg1916
2009-02-10 00:00:00admincreate