Title
for-range-declaration of an expansion-statement as a templated entity
Status
tentatively ready
Section
13.1 [temp.pre]
Submitter
AT

Created on 2025-10-01.00:00:00 last changed 3 weeks ago

Messages

Date: 2025-11-17.18:45:11

Proposed resolution (approved by CWG 2025-11-08):

Change in 13.1 [temp.pre] bullet 8.2 as follows:

An entity is templated if it is
  • a template,
  • an entity defined (6.2 [basic.def]) or created (6.8.7 [class.temporary]) within the for-range-declaration or compound-statement of an expansion-statement (8.7 [stmt.expand]),
  • ...
Date: 2025-11-17.18:45:11
N5028 comment AT 2-089

Currently, a structured binding pack can only be declared in the for-range-declaration of an expansion-statement if there is an enclosing template. Make entities declared therein templated entities.

Consider:

  struct B
  {
    int i;
    long l;
  };

  struct A
  {
    B b;
  };

  void f(int i, long l);

  int main()
  {
    template for (auto [ ... e] : A()) {
      f(e...);   // OK
    }
  }
History
Date User Action Args
2025-11-17 18:45:11adminsetmessages: + msg8380
2025-11-17 18:45:11adminsetstatus: open -> tentatively ready
2025-10-01 00:00:00admincreate