Title
Is a closure type a structural type?
Status
open
Section
7.5.5.2 [expr.prim.lambda.closure]
Submitter
Zhihao Yuan

Created on 2022-03-01.00:00:00 last changed 2 months ago

Messages

Date: 2022-03-01.00:00:00

Consider:

  template <auto V>
  void foo() {}

  void bar() {
    foo<[i = 3] { return i; }>();
  }

It is unclear whether the data members of a closure type are public or private. This makes a difference, since it affects whether a closure type is a structural type or not (13.2 [temp.param] paragraph 7:

A structural type is one of the following:
  • a scalar type, or
  • an lvalue reference type, or
  • a literal class type with the following properties:
    • all base classes and non-static data members are public and non-mutable and
    • the types of all bases classes and non-static data members are structural types or (possibly multi-dimensional) array thereof.
History
Date User Action Args
2022-03-01 00:00:00admincreate