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

2025-12-20


3119. for-range-declaration of an expansion-statement as a templated entity

Section: 13.1  [temp.pre]     Status: tentatively ready     Submitter: AT     Date: 2025-10-01

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
    }
  }

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