Title
Rvalues in destructuring expansion statements
Status
open
Section
8.7 [stmt.expand]
Submitter
Barry Revzin

Created on 2026-01-14.00:00:00 last changed yesterday

Messages

Date: 2026-01-21.21:28:50

Possible resolution:

Change in 8.7 [stmt.expand] bullet 5.3 as follows:

... where N is the structured binding size of the type of the expansion-initializer and Si is
  {
    for-range-declaration = ui vi;
    compound-statement
  }
If the expansion-initializer is an lvalue or the referenced type (9.7 [dcl.struct.bind]) of ui is an lvalue reference type, then vi is ui; otherwise, vi is an xvalue designating what ui designates.
Date: 2026-01-14.00:00:00

(From submission #835.)

Consider:

  auto f() -> std::tuple<int, int&, int&&>;

  auto g() -> void {
    template for (auto&& elem : f()) {
      ;
    }
  }

The type of elem is int& in each iteration, but the intent of P1306R5 was that the first and third iteration yield int&& instead.

History
Date User Action Args
2026-01-21 21:28:50adminsetmessages: + msg8457
2026-01-14 00:00:00admincreate