Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expr.prim.lambda.capture] Question about the example in p9 #1621

Open
cpplearner opened this issue Apr 27, 2017 · 0 comments
Open

[expr.prim.lambda.capture] Question about the example in p9 #1621

cpplearner opened this issue Apr 27, 2017 · 0 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@cpplearner
Copy link
Contributor

This is the example in [expr.prim.lambda.capture]p9:

void f2() {
  int i = 1;
  void g1(int = ([i]{ return i; })()); // ill-formed
  void g2(int = ([i]{ return 0; })()); // ill-formed
  void g3(int = ([=]{ return i; })()); // ill-formed
  void g4(int = ([=]{ return 0; })()); // OK
  void g5(int = ([]{ return sizeof i; })()); // OK
}

My question is, what is the smallest enclosing scope of the lambdas in this example?

According to my understanding, it is the function prototype scope. But then the declaration of g4 is not OK: the smallest enclosing scope of the lambda is not a block scope, and so according to [expr.prim.lambda.capture]p3 no capture-default is allowed.

Note that CWG 1632 is also about [expr.prim.lambda.capture]p3 (previously [expr.prim.lambda]p9).

@zygoloid zygoloid added the cwg Issue must be reviewed by CWG. label Jul 15, 2017
@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

3 participants