Created on 2022-11-08.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4917.
[Drafting note: The note is already repeated every time we talk about "immediate context".]
Modify [meta.type.synop], Table 46 ([tab:meta.unary.prop]) — "Type property predicates" — as indicated:
Table 46: Type property predicates [tab:meta.unary.prop] Template Condition Preconditions … template<class T, class U>
struct reference_constructs_from_temporary;conjunction_v<is_reference<T>, is_constructible<T, U>> is trueT is a reference type, and the initialization T t(VAL<U>); is well-formed and binds t to a temporary object whose lifetime is extended ([class.temporary]). Access checking is performed as if in a context unrelated to T and U. Only the validity of the immediate context of the variable initialization is considered. [Note ?: The initialization can result in effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such effects are not in the "immediate context" and can result in the program being ill-formed. — end note]T and U shall be complete types, cv void, or arrays of unknown bound. template<class T, class U>
struct reference_converts_from_temporary;conjunction_v<is_reference<T>, is_convertible<U, T>> is trueT is a reference type, and the initialization T t = VAL<U>; is well-formed and binds t to a temporary object whose lifetime is extended ([class.temporary]). Access checking is performed as if in a context unrelated to T and U. Only the validity of the immediate context of the variable initialization is considered. [Note ?: The initialization can result in effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such effects are not in the "immediate context" and can result in the program being ill-formed. — end note]T and U shall be complete types, cv void, or arrays of unknown bound.
[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP. ]
[ Kona 2022-11-08; Move to Tentatively Ready ]
The intent of P2255R2 is for the reference_meows_from_temporary traits to fully support cases where a prvalue is used as the source. Unfortunately the wording fails to do so because it tries to use the is_meowible traits to say "the initialization is well-formed", but those traits only consider initialization from xvalues, not prvalues. For example, given:
struct U { U(); U(U&&) = delete; }; struct T { T(U); };
reference_constructs_from_temporary_v<const T&, U> should be true, but is currently defined as false. We need to spell out the "is well-formed" condition directly.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2023-02-13 10:17:57 | admin | set | messages: + msg13360 |
2023-02-13 10:17:57 | admin | set | status: voting -> wp |
2023-02-06 15:33:48 | admin | set | status: ready -> voting |
2022-11-10 23:33:23 | admin | set | messages: + msg13012 |
2022-11-10 23:33:23 | admin | set | status: new -> ready |
2022-11-08 15:49:09 | admin | set | messages: + msg12956 |
2022-11-08 00:00:00 | admin | create |