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


3135. Structured bindings with prvalues from tuples

Section: 9.7  [dcl.struct.bind]     Status: open     Submitter: Barry Revzin     Date: 2025-11-14

(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.

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 ;