Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[expr.prim.lambda.closure] Conversion to function pointer doesn't account for explicit object parameter CWG2561 #5294

Copy link
Copy link
Open
@brevzin

Description

@brevzin
Issue body actions

Paragraphs 8 and 9 talk about what kind of function pointer a capture-less lambda is convertible to:

... has a conversion function to pointer to function with C++ language linkage having the same parameter and return types as the closure type's function call operator.

and

... The conversion function template has the same invented template parameter list, and the pointer to function has the same parameter types, as the function call operator template.

Those aren't quite right in the case of an explicit object parameter. Since this should probably work:

using P = int(*)(int);

auto f = [](this P, int i) { return i; };
auto g = [](this auto, int i) { return i; };

P pf = f;
P pg = g;

For the non-generic case, something like this:

- having the same parameter and return types as the closure type's function call operator
+ having the same parameter types (excluding the explicit object parameter, if any) and return type as the closure type's function call operator

Though wording this for the generic case is trickier since we need to skip the invented template parameter of the explicit object parameter, which might hypothetically also be used by some other parameter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.Issue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.Issue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.