Issue 3819: reference_meows_from_temporary should not use is_meowible (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
3819. reference_ _meow_s_from_temporary
should not use is_ _meow_ible
Section: 21.3.5.4 [meta.unary.prop] Status: C++23 Submitter: Tim Song Opened: 2022-11-08 Last modified: 2023-11-22
Priority: Not Prioritized
View other active issues in [meta.unary.prop].
View all other issues in [meta.unary.prop].
View all issues with C++23 status.
Discussion:
The intent of P2255R2 is for the reference_ _meow_s_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_ _meow_ible
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.
[Kona 2022-11-08; Move to Tentatively Ready]
[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4917.
[Drafting note: The note is already repeated every time we talk about "immediate context".]
- Modify 21.3.3 [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, is_constructible<T, U>> istrueT is a reference type, and the initialization T t(VAL); is well-formed and binds t to a temporary object whose lifetime is extended (6.7.7 [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, is_convertible<U, T>> istrueT is a reference type, and the initializationT t = VAL; is well-formed and binds t to a temporary object whose lifetime is extended (6.7.7 [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.