CWG Issue 1973 (original) (raw)

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13


1973. Which parameter-declaration-clause in a lambda-expression?

Section: 7.5.6.2 [expr.prim.lambda.closure]Status: DRWPSubmitter: Dinka RannsDate: 2014-07-16

[Accepted as a DR at the June, 2023 meeting.]

According to 7.5.6.2 [expr.prim.lambda.closure] paragraph 3,

The closure type for a lambda-expression has a public inline function call operator (for a non-generic lambda) or function call operator template (for a generic lambda) (12.4.4 [over.call]) whose parameters and return type are described by the lambda-expression's _parameter-declaration-clause_and trailing-return-type respectively, and whose template-parameter-list consists of the specified template-parameter-list, if any.

This is insufficiently precise because the _trailing-return-type_might itself contain a parameter-declaration-clause.

Suggested resolution [SUPERSEDED]:

Change in 7.5.6.1 [expr.prim.lambda.general] paragraph 5 as follows:

If a lambda-declarator does not include a start with a parenthesized parameter-declaration-clause, it is as if () were inserted at the start of the lambda-declarator.A lambda-expression's _parameter-declaration-clause_is the (possibly empty) parameter-declaration-clause of the lambda-expression's lambda-declarator.If the lambda-declarator does not include a trailing-return-type, the lambda return type is auto, which is deduced from return statements as described in 9.2.9.7 [dcl.spec.auto].

Proposed resolution (approved by CWG 2023-02-06):

  1. Change in 7.5.6.2 [expr.prim.lambda.closure] paragraph 3 as follows:

    The closure type for a lambda-expression has a public inline function call operator (for a non-generic lambda) or function call operator template (for a generic lambda) (12.4.4 [over.call]) whose parameters and return type are described by those ofthe lambda-expression's _parameter-declaration-clause_and trailing-return-type respectively, and whose template-parameter-list consists of the specified template-parameter-list, if any.

  2. Change in 7.5.6.1 [expr.prim.lambda.general] paragraph 5 as follows:

    If a lambda-declarator does not include a parameter-declaration-clause, it is as if () were inserted at the start of the lambda-declarator. A lambda-expression's _parameter-declaration-clause_is the parameter-declaration-clause of the lambda-expression's lambda-declarator, if any, or empty otherwise.If the lambda-declarator does not include a trailing-return-type, the lambda return type is auto, which is deduced from return statements as described in 9.2.9.7 [dcl.spec.auto].