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 j so that it compiles #2941

Closed
wants to merge 2 commits into from
Closed

[expr.prim.lambda] Capture j so that it compiles #2941

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 24, 2019

The lambda captured nothing, but it returns the variable from the enclosing block scope. I assume this is editorial, and can easily be fixed by adding &j.

Capture j so that it compiles.
@@ -1589,7 +1589,7 @@
auto x1 = [](int i){ return i; }; // OK: return type is \tcode{int}
auto x2 = []{ return { 1, 2 }; }; // error: deducing return type from \grammarterm{braced-init-list}
int j;
auto x3 = []()->auto&& { return j; }; // OK: return type is \tcode{int\&}
auto x3 = [&j]()->auto&& { return j; }; // OK: return type is \tcode{int\&}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be moving comments around; can you please adjust everything according to our usual comment placement guidance?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry. Just fixed the indent.

Copy link
Contributor

@tkoeppe tkoeppe Jun 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - see wiki, the preferred comment columns are 20, 32, 40, 48, etc. Can you snap to one of those?

Fixed the indent.
@zygoloid
Copy link
Member

j is a global variable here, so capturing it is both unnecessary and ill-formed.

@zygoloid zygoloid closed this Jun 24, 2019
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 24, 2019

Hah, of course :-) I think we had this very issue before, where someone thought this is an excerpt from some function body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants