@@ -487,45 +487,25 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr {
487487
488488 template <class _Yp ,
489489 class _Dp ,
490- __enable_if_t <!is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
490+ __enable_if_t <__compatible_with<_Yp, _Tp>::value &&
491491 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
492492 int > = 0 >
493493 _LIBCPP_HIDE_FROM_ABI shared_ptr (unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
494- #if _LIBCPP_STD_VER >= 14
495- if (__ptr_ == nullptr )
496- __cntrl_ = nullptr ;
497- else
498- #endif
499- {
500- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
501- typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT> _CntrlBlk;
502- __cntrl_ = new _CntrlBlk (__r.get (), std::move (__r.get_deleter ()), _AllocT ());
503- __enable_weak_this (__r.get (), __r.get ());
504- }
505- __r.release ();
506- }
494+ using _AllocT = typename __shared_ptr_default_allocator<_Yp>::type;
507495
508- template <class _Yp ,
509- class _Dp ,
510- class = void ,
511- __enable_if_t <is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
512- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
513- int > = 0 >
514- _LIBCPP_HIDE_FROM_ABI shared_ptr (unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
515- #if _LIBCPP_STD_VER >= 14
516496 if (__ptr_ == nullptr )
517497 __cntrl_ = nullptr ;
518- else
519- #endif
520- {
521- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
522- typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
523- reference_wrapper<__libcpp_remove_reference_t <_Dp> >,
524- _AllocT>
525- _CntrlBlk;
498+ else if constexpr (is_lvalue_reference<_Dp>::value) {
499+ using _CntrlBlk =
500+ __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
501+ reference_wrapper<__libcpp_remove_reference_t <_Dp> >,
502+ _AllocT>;
526503 __cntrl_ = new _CntrlBlk (__r.get (), std::ref (__r.get_deleter ()), _AllocT ());
527- __enable_weak_this (__r.get (), __r.get ());
504+ } else {
505+ using _CntrlBlk = __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT>;
506+ __cntrl_ = new _CntrlBlk (__r.get (), std::move (__r.get_deleter ()), _AllocT ());
528507 }
508+ __enable_weak_this (__r.get (), __r.get ());
529509 __r.release ();
530510 }
531511
0 commit comments