Title
Structured bindings with prvalues from tuples
Status
open
Section
9.7 [dcl.struct.bind]
Submitter
Barry Revzin

Created on 2025-11-14.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-11-23.22:29:16

Suggested resolution:

Change in 9.7 [dcl.struct.bind] paragraph 7 as follows:

... Given the type Ti designated by std::tuple_element<i, E>::type and the type Ui designated by either Ti & or Ti && where Ui is an lvalue reference if the initializer is an lvalue and an rvalue reference otherwise, defined as Ti if the initializer is a prvalue, as "lvalue reference to Ti" if the initializer is an lvalue, or as "rvalue reference to Ti" otherwise, variables are introduced with unique names ri as follows:
  S Ui ri = initializer ;
Date: 2025-11-14.00:00:00

(From submission #807.)

In the tuple case, e.get<i>() or get<i>(e) is used, but the case that those function calls return a prvalue is not properly handled for constexpr. For example, P1789R3 (Library Support for Expansion Statements) added constexpr T get(integer_sequence<...>).

Structured bindings for prvalues should use a non-reference type.

History
Date User Action Args
2025-11-23 22:29:16adminsetmessages: + msg8419
2025-11-14 00:00:00admincreate