Skip to content

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

Closed
@t-lutz

Description

@t-lutz

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&
           ^

Activity

cpplearner

cpplearner commented on Jan 29, 2016

@cpplearner
Contributor

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

t-lutz

t-lutz commented on Jan 29, 2016

@t-lutz
Author

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

changed the title [-]Missing capture default in example 5.1.2.4[/-] [+][expr.prim.lambda] Missing capture default in example 5.1.2.4[/+] on Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @t-lutz@cpplearner

        Issue actions

          [expr.prim.lambda] Missing capture default in example 5.1.2.4 · Issue #609 · cplusplus/draft