Title
Make the closure type of a captureless lambda a structural type
Status
drwp
Section
7.5.6.2 [expr.prim.lambda.closure]
Submitter
Barry Revzin

Created on 2023-12-29.00:00:00 last changed 4 months ago

Messages

Date: 2024-02-02.23:59:16

Proposed resolution (approved by CWG 2024-02-02):

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

    The closure type is not an aggregate type (9.4.2 [dcl.init.aggr]) and not ; it is a structural type (13.2 [temp.param]) if and only if the lambda has no lambda-capture. An implementation may define the closure type differently from ...
  2. Change in 13.6 [temp.type] paragraph 2 as follows:

    Two values are template-argument-equivalent if they are of the same type and
    • ...
    • they are of a closure type (7.5.6.2 [expr.prim.lambda.closure]), or
    • they are of class type and their corresponding direct subobjects and reference members are template-argument-equivalent.
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

Issue 2542 (approved in June, 2023) made all closure types not be structural types, i.e. unsuitable for use as non-type template parameters. This causes an inconsistency with the treatment of the pointer-to-function conversion for closure types with no captures:

  template <auto V>
  void foo() {}

  void bar() {
    foo<[i = 3] { return i; }>();   // #1: error
    foo<[]{}>();                    // #2: error
    foo<+[]{}>();                   // #3: OK, a function pointer is a structural type
  }
History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2024-02-02 23:59:16adminsetmessages: + msg7585
2024-02-02 23:59:16adminsetstatus: review -> tentatively ready
2024-01-21 13:30:12adminsetstatus: open -> review
2023-12-29 00:00:00admincreate