Skip to content

Commit 6951fbe

Browse files
committed
Remove __can_bind_reference() in favor of __reference_constructs_from_temporary_v
1 parent 7d00f7e commit 6951fbe

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

libcxx/include/optional

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -424,28 +424,12 @@ struct __optional_storage_base<_Tp, true> {
424424
using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>;
425425
__raw_type* __value_;
426426

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-
443427
_LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base() noexcept : __value_(nullptr) {}
444428

445429
template <class _UArg>
446430
_LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_storage_base(in_place_t, _UArg&& __uarg)
447431
: __value_(std::addressof(__uarg)) {
448-
static_assert(__can_bind_reference<_UArg>(),
432+
static_assert(!__reference_constructs_from_temporary_v<_Tp, _UArg>,
449433
"Attempted to construct a reference element in tuple from a "
450434
"possible temporary");
451435
}
@@ -461,7 +445,7 @@ struct __optional_storage_base<_Tp, true> {
461445
template <class _UArg>
462446
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val) {
463447
_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>,
465449
"Attempted to construct a reference element in tuple from a "
466450
"possible temporary");
467451
__value_ = std::addressof(__val);

0 commit comments

Comments
 (0)