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] Missing capture default in example 5.1.2.4 #609

Closed
t-lutz opened this issue Jan 28, 2016 · 2 comments
Closed

[expr.prim.lambda] Missing capture default in example 5.1.2.4 #609

t-lutz opened this issue Jan 28, 2016 · 2 comments

Comments

@t-lutz
Copy link

t-lutz commented Jan 28, 2016

The last two lines of the example read:

int j;
auto x3 = []()->auto&& { return j; }; // OK: return type is int&

However j is not captured and the lambda doesn't have a default capture.

The correct code should be:

int j;
auto x3 = [&]()->auto&& { return j; }; // OK: return type is int&
           ^
@cpplearner
Copy link
Contributor

I think j should be interpreted as having namespace scope, so it needn't (and can't) be captured.

@t-lutz t-lutz closed this as completed Jan 29, 2016
@t-lutz
Copy link
Author

t-lutz commented Jan 29, 2016

My bad., I wrongly reproduced the example with j in a local scope.

@jensmaurer jensmaurer changed the title Missing capture default in example 5.1.2.4 [expr.prim.lambda] Missing capture default in example 5.1.2.4 Sep 15, 2017
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

No branches or pull requests

2 participants