reference_constructs_from_temporary/reference_converts_from_temporary
seem wrongSection: 21.3.5.4 [meta.unary.prop] Status: New Submitter: Jiang An Opened: 2022-05-10 Last modified: 2022-05-17
Priority: 3
View other active issues in [meta.unary.prop].
View all other issues in [meta.unary.prop].
View all issues with New status.
Discussion:
std::reference_constructs_from_temporary
and std::reference_converts_from_temporary
are only
useful when T
is a reference type, and a reference type is always complete. Whenever T
is an
incomplete object type, it's clear that these traits inherit from std::false_type
, without any further
detection which may result in UB. However, when T
is X&
or X&&
where
X
is an incomplete object type, UB may be needed because of the potentially problematic detection in
std::is_constructible
or std::is_convertible
.
[2022-05-17; Reflector poll]
Set priority to 3 after reflector poll.
Proposed resolution:
This wording is relative to N4910.
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<T>, is_constructible<T, U>>
is
true
, and the initializationT t(VAL<U>);
bindst
to a
temporary object whose lifetime is extended (6.7.7 [class.temporary]).If T
is a reference type,remove_reference_t<T>
andU
shall beT
acomplete types,
cvvoid
, oranarrays of unknown bound.template<class T, class U>
struct reference_converts_from_temporary;conjunction_v<is_reference<T>, is_convertible<U, T>>
is
true
, and the initializationT t = VAL<U>;
bindst
to a
temporary object whose lifetime is extended (6.7.7 [class.temporary]).If T
is a reference type,remove_reference_t<T>
andU
shall be complete types,
cvvoid
, or arrays of unknown bound.