@@ -424,28 +424,12 @@ struct __optional_storage_base<_Tp, true> {
424
424
using __raw_type _LIBCPP_NODEBUG = remove_reference_t <_Tp>;
425
425
__raw_type* __value_;
426
426
427
- template <class _Up >
428
- static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference () {
429
- using _RawUp = __libcpp_remove_reference_t <_Up>;
430
- using _UpPtr = _RawUp*;
431
- using _RawTp = __libcpp_remove_reference_t <_Tp>;
432
- using _TpPtr = _RawTp*;
433
- using _CheckLValueArg =
434
- integral_constant<bool ,
435
- (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value) ||
436
- is_same<_RawUp, reference_wrapper<_RawTp>>::value ||
437
- is_same<_RawUp, reference_wrapper<__remove_const_t <_RawTp>>>::value >;
438
- return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value) ||
439
- (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&
440
- is_convertible<_UpPtr, _TpPtr>::value);
441
- }
442
-
443
427
_LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base () noexcept : __value_(nullptr ) {}
444
428
445
429
template <class _UArg >
446
430
_LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_storage_base (in_place_t , _UArg&& __uarg)
447
431
: __value_(std::addressof(__uarg)) {
448
- static_assert (__can_bind_reference< _UArg>() ,
432
+ static_assert (!__reference_constructs_from_temporary_v<_Tp, _UArg>,
449
433
" Attempted to construct a reference element in tuple from a "
450
434
" possible temporary" );
451
435
}
@@ -461,7 +445,7 @@ struct __optional_storage_base<_Tp, true> {
461
445
template <class _UArg >
462
446
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct (_UArg&& __val) {
463
447
_LIBCPP_ASSERT_INTERNAL (!has_value (), " __construct called for engaged __optional_storage" );
464
- static_assert (__can_bind_reference< _UArg>() ,
448
+ static_assert (!__reference_constructs_from_temporary_v<_Tp, _UArg>,
465
449
" Attempted to construct a reference element in tuple from a "
466
450
" possible temporary" );
467
451
__value_ = std::addressof (__val);
0 commit comments