49 #ifndef _SHARED_PTR_BASE_H 50 #define _SHARED_PTR_BASE_H 1 58 namespace std _GLIBCXX_VISIBILITY(default)
60 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 #if _GLIBCXX_USE_DEPRECATED 63 #pragma GCC diagnostic push 64 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 65 template<
typename>
class auto_ptr;
66 #pragma GCC diagnostic pop 76 virtual char const*
what()
const noexcept;
83 __throw_bad_weak_ptr()
86 using __gnu_cxx::_Lock_policy;
87 using __gnu_cxx::__default_lock_policy;
88 using __gnu_cxx::_S_single;
89 using __gnu_cxx::_S_mutex;
90 using __gnu_cxx::_S_atomic;
93 template<_Lock_policy _Lp>
98 enum { _S_need_barriers = 0 };
102 class _Mutex_base<_S_mutex>
103 :
public __gnu_cxx::__mutex
109 enum { _S_need_barriers = 1 };
112 template<_Lock_policy _Lp = __default_lock_policy>
113 class _Sp_counted_base
114 :
public _Mutex_base<_Lp>
117 _Sp_counted_base() noexcept
118 : _M_use_count(1), _M_weak_count(1) { }
121 ~_Sp_counted_base() noexcept
127 _M_dispose() noexcept = 0;
131 _M_destroy() noexcept
139 { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
145 _M_add_ref_lock_nothrow();
148 _M_release() noexcept
151 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
152 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
154 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count);
160 if (_Mutex_base<_Lp>::_S_need_barriers)
162 __atomic_thread_fence (__ATOMIC_ACQ_REL);
166 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
167 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
170 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
177 _M_weak_add_ref() noexcept
178 { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
181 _M_weak_release() noexcept
184 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
185 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
187 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
188 if (_Mutex_base<_Lp>::_S_need_barriers)
192 __atomic_thread_fence (__ATOMIC_ACQ_REL);
199 _M_get_use_count() const noexcept
203 return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
207 _Sp_counted_base(_Sp_counted_base
const&) =
delete;
208 _Sp_counted_base& operator=(_Sp_counted_base
const&) =
delete;
210 _Atomic_word _M_use_count;
211 _Atomic_word _M_weak_count;
216 _Sp_counted_base<_S_single>::
219 if (_M_use_count == 0)
220 __throw_bad_weak_ptr();
226 _Sp_counted_base<_S_mutex>::
230 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
233 __throw_bad_weak_ptr();
239 _Sp_counted_base<_S_atomic>::
243 _Atomic_word __count = _M_get_use_count();
247 __throw_bad_weak_ptr();
251 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
252 true, __ATOMIC_ACQ_REL,
258 _Sp_counted_base<_S_single>::
259 _M_add_ref_lock_nothrow()
261 if (_M_use_count == 0)
269 _Sp_counted_base<_S_mutex>::
270 _M_add_ref_lock_nothrow()
273 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
283 _Sp_counted_base<_S_atomic>::
284 _M_add_ref_lock_nothrow()
287 _Atomic_word __count = _M_get_use_count();
295 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
296 true, __ATOMIC_ACQ_REL,
303 _Sp_counted_base<_S_single>::_M_add_ref_copy()
308 _Sp_counted_base<_S_single>::_M_release() noexcept
310 if (--_M_use_count == 0)
313 if (--_M_weak_count == 0)
320 _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
325 _Sp_counted_base<_S_single>::_M_weak_release() noexcept
327 if (--_M_weak_count == 0)
333 _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
334 {
return _M_use_count; }
338 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
341 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
344 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
345 class __enable_shared_from_this;
347 template<
typename _Tp>
350 template<
typename _Tp>
353 template<
typename _Tp>
356 template<
typename _Tp>
357 class enable_shared_from_this;
359 template<_Lock_policy _Lp = __default_lock_policy>
362 template<_Lock_policy _Lp = __default_lock_policy>
363 class __shared_count;
367 template<
typename _Ptr, _Lock_policy _Lp>
368 class _Sp_counted_ptr final :
public _Sp_counted_base<_Lp>
372 _Sp_counted_ptr(_Ptr __p) noexcept
376 _M_dispose() noexcept
380 _M_destroy() noexcept
387 _Sp_counted_ptr(
const _Sp_counted_ptr&) =
delete;
388 _Sp_counted_ptr& operator=(
const _Sp_counted_ptr&) =
delete;
396 _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
400 _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
404 _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
406 template<
int _Nm,
typename _Tp,
407 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
408 struct _Sp_ebo_helper;
411 template<
int _Nm,
typename _Tp>
412 struct _Sp_ebo_helper<_Nm, _Tp, true> :
private _Tp
414 explicit _Sp_ebo_helper(
const _Tp& __tp) : _Tp(__tp) { }
415 explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { }
418 _S_get(_Sp_ebo_helper& __eboh) {
return static_cast<_Tp&
>(__eboh); }
422 template<
int _Nm,
typename _Tp>
423 struct _Sp_ebo_helper<_Nm, _Tp, false>
425 explicit _Sp_ebo_helper(
const _Tp& __tp) : _M_tp(__tp) { }
426 explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
429 _S_get(_Sp_ebo_helper& __eboh)
430 {
return __eboh._M_tp; }
437 template<
typename _Ptr,
typename _Deleter,
typename _Alloc, _Lock_policy _Lp>
438 class _Sp_counted_deleter final :
public _Sp_counted_base<_Lp>
440 class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc>
442 typedef _Sp_ebo_helper<0, _Deleter> _Del_base;
443 typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base;
446 _Impl(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
447 : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a)
450 _Deleter& _M_del() noexcept {
return _Del_base::_S_get(*
this); }
451 _Alloc& _M_alloc() noexcept {
return _Alloc_base::_S_get(*
this); }
457 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;
460 _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept
461 : _M_impl(__p, std::move(__d), _Alloc()) { }
464 _Sp_counted_deleter(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
465 : _M_impl(__p, std::move(__d), __a) { }
467 ~_Sp_counted_deleter() noexcept { }
470 _M_dispose() noexcept
471 { _M_impl._M_del()(_M_impl._M_ptr); }
474 _M_destroy() noexcept
476 __allocator_type __a(_M_impl._M_alloc());
477 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
478 this->~_Sp_counted_deleter();
487 return __ti ==
typeid(_Deleter)
501 struct _Sp_make_shared_tag
504 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
505 friend class _Sp_counted_ptr_inplace;
507 static const type_info&
508 _S_ti() noexcept _GLIBCXX_VISIBILITY(default)
510 alignas(type_info)
static constexpr
char __tag[
sizeof(type_info)] = { };
511 return reinterpret_cast<const type_info&
>(__tag);
514 static bool _S_eq(
const type_info&) noexcept;
517 template<
typename _Alloc>
518 struct _Sp_alloc_shared_tag
523 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
524 class _Sp_counted_ptr_inplace final :
public _Sp_counted_base<_Lp>
526 class _Impl : _Sp_ebo_helper<0, _Alloc>
528 typedef _Sp_ebo_helper<0, _Alloc> _A_base;
531 explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { }
533 _Alloc& _M_alloc() noexcept {
return _A_base::_S_get(*
this); }
535 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
539 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
542 template<
typename... _Args>
543 _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
549 std::forward<_Args>(__args)...);
552 ~_Sp_counted_ptr_inplace() noexcept { }
555 _M_dispose() noexcept
562 _M_destroy() noexcept
564 __allocator_type __a(_M_impl._M_alloc());
565 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
566 this->~_Sp_counted_ptr_inplace();
570 friend class __shared_count<_Lp>;
577 auto __ptr =
const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
582 if (&__ti == &_Sp_make_shared_tag::_S_ti()
585 __ti ==
typeid(_Sp_make_shared_tag)
587 _Sp_make_shared_tag::_S_eq(__ti)
594 _Tp* _M_ptr() noexcept {
return _M_impl._M_storage._M_ptr(); }
600 struct __sp_array_delete
602 template<
typename _Yp>
603 void operator()(_Yp* __p)
const {
delete[] __p; }
606 template<_Lock_policy _Lp>
609 template<
typename _Tp>
610 struct __not_alloc_shared_tag {
using type = void; };
612 template<
typename _Tp>
613 struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { };
616 constexpr __shared_count() noexcept : _M_pi(0)
619 template<
typename _Ptr>
621 __shared_count(_Ptr __p) : _M_pi(0)
625 _M_pi =
new _Sp_counted_ptr<_Ptr, _Lp>(__p);
630 __throw_exception_again;
634 template<
typename _Ptr>
636 : __shared_count(__p)
639 template<
typename _Ptr>
641 : __shared_count(__p, __sp_array_delete{}, allocator<void>())
644 template<
typename _Ptr,
typename _Deleter,
645 typename =
typename __not_alloc_shared_tag<_Deleter>::type>
646 __shared_count(_Ptr __p, _Deleter __d)
647 : __shared_count(__p,
std::move(__d), allocator<void>())
650 template<
typename _Ptr,
typename _Deleter,
typename _Alloc,
651 typename =
typename __not_alloc_shared_tag<_Deleter>::type>
652 __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0)
654 typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type;
657 typename _Sp_cd_type::__allocator_type __a2(__a);
659 _Sp_cd_type* __mem = __guard.get();
660 ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a));
667 __throw_exception_again;
671 template<
typename _Tp,
typename _Alloc,
typename... _Args>
672 __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a,
675 typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
676 typename _Sp_cp_type::__allocator_type __a2(__a._M_a);
678 _Sp_cp_type* __mem = __guard.get();
679 auto __pi = ::new (__mem)
680 _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
683 __p = __pi->_M_ptr();
686 #if _GLIBCXX_USE_DEPRECATED 687 #pragma GCC diagnostic push 688 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 690 template<
typename _Tp>
693 #pragma GCC diagnostic pop 697 template<
typename _Tp,
typename _Del>
703 if (__r.get() ==
nullptr)
706 using _Ptr =
typename unique_ptr<_Tp, _Del>::pointer;
707 using _Del2 =
typename conditional<is_reference<_Del>::value,
708 reference_wrapper<typename remove_reference<_Del>::type>,
711 = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
712 using _Alloc = allocator<_Sp_cd_type>;
713 using _Alloc_traits = allocator_traits<_Alloc>;
715 _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1);
716 _Alloc_traits::construct(__a, __mem, __r.release(),
722 explicit __shared_count(
const __weak_count<_Lp>& __r);
725 explicit __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t);
727 ~__shared_count() noexcept
729 if (_M_pi !=
nullptr)
733 __shared_count(
const __shared_count& __r) noexcept
737 _M_pi->_M_add_ref_copy();
741 operator=(
const __shared_count& __r) noexcept
743 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
747 __tmp->_M_add_ref_copy();
756 _M_swap(__shared_count& __r) noexcept
758 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
764 _M_get_use_count() const noexcept
765 {
return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
768 _M_unique() const noexcept
769 {
return this->_M_get_use_count() == 1; }
773 {
return _M_pi ? _M_pi->_M_get_deleter(__ti) :
nullptr; }
776 _M_less(
const __shared_count& __rhs)
const noexcept
780 _M_less(
const __weak_count<_Lp>& __rhs)
const noexcept
785 operator==(
const __shared_count& __a,
const __shared_count& __b) noexcept
786 {
return __a._M_pi == __b._M_pi; }
789 friend class __weak_count<_Lp>;
791 _Sp_counted_base<_Lp>* _M_pi;
795 template<_Lock_policy _Lp>
799 constexpr __weak_count() noexcept : _M_pi(
nullptr)
802 __weak_count(
const __shared_count<_Lp>& __r) noexcept
805 if (_M_pi !=
nullptr)
806 _M_pi->_M_weak_add_ref();
809 __weak_count(
const __weak_count& __r) noexcept
812 if (_M_pi !=
nullptr)
813 _M_pi->_M_weak_add_ref();
816 __weak_count(__weak_count&& __r) noexcept
818 { __r._M_pi =
nullptr; }
820 ~__weak_count() noexcept
822 if (_M_pi !=
nullptr)
823 _M_pi->_M_weak_release();
827 operator=(
const __shared_count<_Lp>& __r) noexcept
829 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
830 if (__tmp !=
nullptr)
831 __tmp->_M_weak_add_ref();
832 if (_M_pi !=
nullptr)
833 _M_pi->_M_weak_release();
839 operator=(
const __weak_count& __r) noexcept
841 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
842 if (__tmp !=
nullptr)
843 __tmp->_M_weak_add_ref();
844 if (_M_pi !=
nullptr)
845 _M_pi->_M_weak_release();
851 operator=(__weak_count&& __r) noexcept
853 if (_M_pi !=
nullptr)
854 _M_pi->_M_weak_release();
861 _M_swap(__weak_count& __r) noexcept
863 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
869 _M_get_use_count() const noexcept
870 {
return _M_pi !=
nullptr ? _M_pi->_M_get_use_count() : 0; }
873 _M_less(
const __weak_count& __rhs)
const noexcept
877 _M_less(
const __shared_count<_Lp>& __rhs)
const noexcept
882 operator==(
const __weak_count& __a,
const __weak_count& __b) noexcept
883 {
return __a._M_pi == __b._M_pi; }
886 friend class __shared_count<_Lp>;
888 _Sp_counted_base<_Lp>* _M_pi;
892 template<_Lock_policy _Lp>
894 __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
897 if (_M_pi !=
nullptr)
898 _M_pi->_M_add_ref_lock();
900 __throw_bad_weak_ptr();
904 template<_Lock_policy _Lp>
906 __shared_count<_Lp>::
907 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t)
910 if (_M_pi !=
nullptr)
911 if (!_M_pi->_M_add_ref_lock_nothrow())
915 #define __cpp_lib_shared_ptr_arrays 201611L 921 template<
typename _Yp_ptr,
typename _Tp_ptr>
922 struct __sp_compatible_with
926 template<
typename _Yp,
typename _Tp>
927 struct __sp_compatible_with<_Yp*, _Tp*>
928 : is_convertible<_Yp*, _Tp*>::type
931 template<
typename _Up,
size_t _Nm>
932 struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
936 template<
typename _Up,
size_t _Nm>
937 struct __sp_compatible_with<_Up(*)[_Nm],
const _Up(*)[]>
941 template<
typename _Up,
size_t _Nm>
942 struct __sp_compatible_with<_Up(*)[_Nm],
volatile _Up(*)[]>
946 template<
typename _Up,
size_t _Nm>
947 struct __sp_compatible_with<_Up(*)[_Nm],
const volatile _Up(*)[]>
952 template<
typename _Up,
size_t _Nm,
typename _Yp,
typename =
void>
953 struct __sp_is_constructible_arrN
957 template<
typename _Up,
size_t _Nm,
typename _Yp>
958 struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
959 : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
963 template<
typename _Up,
typename _Yp,
typename =
void>
964 struct __sp_is_constructible_arr
968 template<
typename _Up,
typename _Yp>
969 struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
970 : is_convertible<_Yp(*)[], _Up(*)[]>::type
974 template<
typename _Tp,
typename _Yp>
975 struct __sp_is_constructible;
978 template<
typename _Up,
size_t _Nm,
typename _Yp>
979 struct __sp_is_constructible<_Up[_Nm], _Yp>
980 : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
984 template<
typename _Up,
typename _Yp>
985 struct __sp_is_constructible<_Up[], _Yp>
986 : __sp_is_constructible_arr<_Up, _Yp>::type
990 template<
typename _Tp,
typename _Yp>
991 struct __sp_is_constructible
992 : is_convertible<_Yp*, _Tp*>::type
997 template<
typename _Tp, _Lock_policy _Lp,
998 bool = is_array<_Tp>::value,
bool = is_void<_Tp>::value>
999 class __shared_ptr_access
1002 using element_type = _Tp;
1007 __glibcxx_assert(_M_get() !=
nullptr);
1012 operator->() const noexcept
1014 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1020 _M_get() const noexcept
1021 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
1025 template<
typename _Tp, _Lock_policy _Lp>
1026 class __shared_ptr_access<_Tp, _Lp, false, true>
1029 using element_type = _Tp;
1032 operator->() const noexcept
1034 auto __ptr =
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get();
1035 _GLIBCXX_DEBUG_PEDASSERT(__ptr !=
nullptr);
1041 template<
typename _Tp, _Lock_policy _Lp>
1042 class __shared_ptr_access<_Tp, _Lp, true, false>
1045 using element_type =
typename remove_extent<_Tp>::type;
1047 #if __cplusplus <= 201402L 1048 [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
1052 __glibcxx_assert(_M_get() !=
nullptr);
1056 [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
1058 operator->() const noexcept
1060 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1066 operator[](ptrdiff_t __i)
const 1068 __glibcxx_assert(_M_get() !=
nullptr);
1069 __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
1070 return _M_get()[__i];
1075 _M_get() const noexcept
1076 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
1079 template<
typename _Tp, _Lock_policy _Lp>
1081 :
public __shared_ptr_access<_Tp, _Lp>
1084 using element_type =
typename remove_extent<_Tp>::type;
1088 template<
typename _Yp>
1090 =
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
1093 template<
typename _Yp,
typename _Res =
void>
1094 using _Compatible =
typename 1095 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1098 template<
typename _Yp>
1099 using _Assignable = _Compatible<_Yp, __shared_ptr&>;
1102 template<
typename _Yp,
typename _Del,
typename _Res = void,
1103 typename _Ptr =
typename unique_ptr<_Yp, _Del>::pointer>
1104 using _UniqCompatible =
typename enable_if<__and_<
1105 __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
1106 >::value, _Res>::type;
1109 template<
typename _Yp,
typename _Del>
1110 using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
1114 #if __cplusplus > 201402L 1115 using weak_type = __weak_ptr<_Tp, _Lp>;
1118 constexpr __shared_ptr() noexcept
1119 : _M_ptr(0), _M_refcount()
1122 template<
typename _Yp,
typename = _SafeConv<_Yp>>
1124 __shared_ptr(_Yp* __p)
1125 : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
1127 static_assert( !is_void<_Yp>::value,
"incomplete type" );
1128 static_assert(
sizeof(_Yp) > 0,
"incomplete type" );
1129 _M_enable_shared_from_this_with(__p);
1132 template<
typename _Yp,
typename _Deleter,
typename = _SafeConv<_Yp>>
1133 __shared_ptr(_Yp* __p, _Deleter __d)
1134 : _M_ptr(__p), _M_refcount(__p,
std::move(__d))
1136 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1137 "deleter expression d(p) is well-formed");
1138 _M_enable_shared_from_this_with(__p);
1141 template<
typename _Yp,
typename _Deleter,
typename _Alloc,
1142 typename = _SafeConv<_Yp>>
1143 __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
1144 : _M_ptr(__p), _M_refcount(__p,
std::move(__d),
std::move(__a))
1146 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1147 "deleter expression d(p) is well-formed");
1148 _M_enable_shared_from_this_with(__p);
1151 template<
typename _Deleter>
1152 __shared_ptr(nullptr_t __p, _Deleter __d)
1153 : _M_ptr(0), _M_refcount(__p,
std::move(__d))
1156 template<
typename _Deleter,
typename _Alloc>
1157 __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
1158 : _M_ptr(0), _M_refcount(__p,
std::move(__d),
std::move(__a))
1161 template<
typename _Yp>
1162 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
1163 element_type* __p) noexcept
1164 : _M_ptr(__p), _M_refcount(__r._M_refcount)
1167 __shared_ptr(
const __shared_ptr&) noexcept =
default;
1168 __shared_ptr& operator=(
const __shared_ptr&) noexcept =
default;
1169 ~__shared_ptr() =
default;
1171 template<
typename _Yp,
typename = _Compatible<_Yp>>
1172 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1173 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1176 __shared_ptr(__shared_ptr&& __r) noexcept
1177 : _M_ptr(__r._M_ptr), _M_refcount()
1179 _M_refcount._M_swap(__r._M_refcount);
1183 template<
typename _Yp,
typename = _Compatible<_Yp>>
1184 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1185 : _M_ptr(__r._M_ptr), _M_refcount()
1187 _M_refcount._M_swap(__r._M_refcount);
1191 template<
typename _Yp,
typename = _Compatible<_Yp>>
1192 explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
1193 : _M_refcount(__r._M_refcount)
1197 _M_ptr = __r._M_ptr;
1201 template<
typename _Yp,
typename _Del,
1202 typename = _UniqCompatible<_Yp, _Del>>
1203 __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
1204 : _M_ptr(__r.get()), _M_refcount()
1206 auto __raw = __to_address(__r.get());
1207 _M_refcount = __shared_count<_Lp>(std::move(__r));
1208 _M_enable_shared_from_this_with(__raw);
1211 #if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED 1214 template<
typename _Tp1,
typename _Del,
1215 typename enable_if<__and_<
1216 __not_<is_array<_Tp>>, is_array<_Tp1>,
1217 is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
1218 >::value,
bool>::type =
true>
1219 __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
1220 : _M_ptr(__r.get()), _M_refcount()
1222 auto __raw = __to_address(__r.get());
1223 _M_refcount = __shared_count<_Lp>(std::move(__r));
1224 _M_enable_shared_from_this_with(__raw);
1229 #if _GLIBCXX_USE_DEPRECATED 1230 #pragma GCC diagnostic push 1231 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 1233 template<
typename _Yp,
typename = _Compatible<_Yp>>
1234 __shared_ptr(auto_ptr<_Yp>&& __r);
1235 #pragma GCC diagnostic pop 1238 constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
1240 template<
typename _Yp>
1242 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1244 _M_ptr = __r._M_ptr;
1245 _M_refcount = __r._M_refcount;
1249 #if _GLIBCXX_USE_DEPRECATED 1250 #pragma GCC diagnostic push 1251 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 1252 template<
typename _Yp>
1254 operator=(auto_ptr<_Yp>&& __r)
1256 __shared_ptr(std::move(__r)).swap(*
this);
1259 #pragma GCC diagnostic pop 1263 operator=(__shared_ptr&& __r) noexcept
1265 __shared_ptr(std::move(__r)).swap(*
this);
1271 operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1273 __shared_ptr(std::move(__r)).swap(*
this);
1277 template<
typename _Yp,
typename _Del>
1278 _UniqAssignable<_Yp, _Del>
1279 operator=(unique_ptr<_Yp, _Del>&& __r)
1281 __shared_ptr(std::move(__r)).swap(*
this);
1287 { __shared_ptr().swap(*
this); }
1289 template<
typename _Yp>
1294 __glibcxx_assert(__p == 0 || __p != _M_ptr);
1295 __shared_ptr(__p).swap(*
this);
1298 template<
typename _Yp,
typename _Deleter>
1300 reset(_Yp* __p, _Deleter __d)
1301 { __shared_ptr(__p, std::move(__d)).swap(*
this); }
1303 template<
typename _Yp,
typename _Deleter,
typename _Alloc>
1305 reset(_Yp* __p, _Deleter __d, _Alloc __a)
1306 { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*
this); }
1309 get()
const noexcept
1312 explicit operator bool() const
1313 {
return _M_ptr == 0 ? false :
true; }
1316 unique() const noexcept
1317 {
return _M_refcount._M_unique(); }
1320 use_count() const noexcept
1321 {
return _M_refcount._M_get_use_count(); }
1324 swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
1326 std::swap(_M_ptr, __other._M_ptr);
1327 _M_refcount._M_swap(__other._M_refcount);
1330 template<
typename _Tp1>
1332 owner_before(__shared_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1333 {
return _M_refcount._M_less(__rhs._M_refcount); }
1335 template<
typename _Tp1>
1337 owner_before(__weak_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1338 {
return _M_refcount._M_less(__rhs._M_refcount); }
1342 template<
typename _Alloc,
typename... _Args>
1343 __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
1344 : _M_ptr(), _M_refcount(_M_ptr, __tag,
std::
forward<_Args>(__args)...)
1345 { _M_enable_shared_from_this_with(_M_ptr); }
1347 template<
typename _Tp1, _Lock_policy _Lp1,
typename _Alloc,
1349 friend __shared_ptr<_Tp1, _Lp1>
1350 __allocate_shared(
const _Alloc& __a, _Args&&... __args);
1354 __shared_ptr(
const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t)
1355 : _M_refcount(__r._M_refcount,
std::nothrow)
1357 _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr :
nullptr;
1360 friend class __weak_ptr<_Tp, _Lp>;
1364 template<
typename _Yp>
1365 using __esft_base_t = decltype(__enable_shared_from_this_base(
1366 std::declval<
const __shared_count<_Lp>&>(),
1367 std::declval<_Yp*>()));
1370 template<
typename _Yp,
typename =
void>
1371 struct __has_esft_base
1374 template<
typename _Yp>
1375 struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
1376 : __not_<is_array<_Tp>> { };
1378 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1379 typename enable_if<__has_esft_base<_Yp2>::value>::type
1380 _M_enable_shared_from_this_with(_Yp* __p) noexcept
1382 if (
auto __base = __enable_shared_from_this_base(_M_refcount, __p))
1383 __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount);
1386 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1387 typename enable_if<!__has_esft_base<_Yp2>::value>::type
1388 _M_enable_shared_from_this_with(_Yp*) noexcept
1393 {
return _M_refcount._M_get_deleter(__ti); }
1395 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1396 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1398 template<
typename _Del,
typename _Tp1, _Lock_policy _Lp1>
1399 friend _Del* get_deleter(
const __shared_ptr<_Tp1, _Lp1>&) noexcept;
1401 template<
typename _Del,
typename _Tp1>
1402 friend _Del* get_deleter(
const shared_ptr<_Tp1>&) noexcept;
1404 element_type* _M_ptr;
1405 __shared_count<_Lp> _M_refcount;
1410 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1412 operator==(
const __shared_ptr<_Tp1, _Lp>& __a,
1413 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1414 {
return __a.get() == __b.get(); }
1416 template<
typename _Tp, _Lock_policy _Lp>
1418 operator==(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1421 template<
typename _Tp, _Lock_policy _Lp>
1423 operator==(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1426 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1428 operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
1429 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1430 {
return __a.get() != __b.get(); }
1432 template<
typename _Tp, _Lock_policy _Lp>
1434 operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1435 {
return (
bool)__a; }
1437 template<
typename _Tp, _Lock_policy _Lp>
1439 operator!=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1440 {
return (
bool)__a; }
1442 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1444 operator<(const __shared_ptr<_Tp, _Lp>& __a,
1445 const __shared_ptr<_Up, _Lp>& __b) noexcept
1447 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1448 using _Up_elt =
typename __shared_ptr<_Up, _Lp>::element_type;
1449 using _Vp =
typename common_type<_Tp_elt*, _Up_elt*>::type;
1450 return less<_Vp>()(__a.get(), __b.get());
1453 template<
typename _Tp, _Lock_policy _Lp>
1455 operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1457 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1458 return less<_Tp_elt*>()(__a.get(),
nullptr);
1461 template<
typename _Tp, _Lock_policy _Lp>
1463 operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1465 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1466 return less<_Tp_elt*>()(
nullptr, __a.get());
1469 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1471 operator<=(const __shared_ptr<_Tp1, _Lp>& __a,
1472 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1473 {
return !(__b < __a); }
1475 template<
typename _Tp, _Lock_policy _Lp>
1477 operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1478 {
return !(
nullptr < __a); }
1480 template<
typename _Tp, _Lock_policy _Lp>
1482 operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1483 {
return !(__a <
nullptr); }
1485 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1487 operator>(
const __shared_ptr<_Tp1, _Lp>& __a,
1488 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1489 {
return (__b < __a); }
1491 template<
typename _Tp, _Lock_policy _Lp>
1493 operator>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1494 {
return nullptr < __a; }
1496 template<
typename _Tp, _Lock_policy _Lp>
1498 operator>(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1499 {
return __a <
nullptr; }
1501 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1503 operator>=(
const __shared_ptr<_Tp1, _Lp>& __a,
1504 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1505 {
return !(__a < __b); }
1507 template<
typename _Tp, _Lock_policy _Lp>
1509 operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1510 {
return !(__a <
nullptr); }
1512 template<
typename _Tp, _Lock_policy _Lp>
1514 operator>=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1515 {
return !(
nullptr < __a); }
1518 template<
typename _Tp, _Lock_policy _Lp>
1520 swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
1530 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1531 inline __shared_ptr<_Tp, _Lp>
1534 using _Sp = __shared_ptr<_Tp, _Lp>;
1535 return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get()));
1543 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1544 inline __shared_ptr<_Tp, _Lp>
1547 using _Sp = __shared_ptr<_Tp, _Lp>;
1548 return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get()));
1556 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1557 inline __shared_ptr<_Tp, _Lp>
1560 using _Sp = __shared_ptr<_Tp, _Lp>;
1561 if (
auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get()))
1562 return _Sp(__r, __p);
1566 #if __cplusplus > 201402L 1567 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1568 inline __shared_ptr<_Tp, _Lp>
1569 reinterpret_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1571 using _Sp = __shared_ptr<_Tp, _Lp>;
1572 return _Sp(__r, reinterpret_cast<typename _Sp::element_type*>(__r.get()));
1576 template<
typename _Tp, _Lock_policy _Lp>
1579 template<
typename _Yp,
typename _Res =
void>
1580 using _Compatible =
typename 1581 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1584 template<
typename _Yp>
1585 using _Assignable = _Compatible<_Yp, __weak_ptr&>;
1588 using element_type =
typename remove_extent<_Tp>::type;
1590 constexpr __weak_ptr() noexcept
1591 : _M_ptr(
nullptr), _M_refcount()
1594 __weak_ptr(
const __weak_ptr&) noexcept =
default;
1596 ~__weak_ptr() =
default;
1612 template<
typename _Yp,
typename = _Compatible<_Yp>>
1613 __weak_ptr(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1614 : _M_refcount(__r._M_refcount)
1615 { _M_ptr = __r.lock().get(); }
1617 template<
typename _Yp,
typename = _Compatible<_Yp>>
1618 __weak_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1619 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1622 __weak_ptr(__weak_ptr&& __r) noexcept
1623 : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount))
1624 { __r._M_ptr =
nullptr; }
1626 template<
typename _Yp,
typename = _Compatible<_Yp>>
1627 __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1628 : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount))
1629 { __r._M_ptr =
nullptr; }
1632 operator=(
const __weak_ptr& __r) noexcept =
default;
1634 template<
typename _Yp>
1636 operator=(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1638 _M_ptr = __r.lock().get();
1639 _M_refcount = __r._M_refcount;
1643 template<
typename _Yp>
1645 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1647 _M_ptr = __r._M_ptr;
1648 _M_refcount = __r._M_refcount;
1653 operator=(__weak_ptr&& __r) noexcept
1655 _M_ptr = __r._M_ptr;
1656 _M_refcount = std::move(__r._M_refcount);
1657 __r._M_ptr =
nullptr;
1661 template<
typename _Yp>
1663 operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1665 _M_ptr = __r.lock().get();
1666 _M_refcount = std::move(__r._M_refcount);
1667 __r._M_ptr =
nullptr;
1671 __shared_ptr<_Tp, _Lp>
1672 lock() const noexcept
1673 {
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
1676 use_count() const noexcept
1677 {
return _M_refcount._M_get_use_count(); }
1680 expired() const noexcept
1681 {
return _M_refcount._M_get_use_count() == 0; }
1683 template<
typename _Tp1>
1685 owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1686 {
return _M_refcount._M_less(__rhs._M_refcount); }
1688 template<
typename _Tp1>
1690 owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1691 {
return _M_refcount._M_less(__rhs._M_refcount); }
1695 { __weak_ptr().swap(*
this); }
1698 swap(__weak_ptr& __s) noexcept
1700 std::swap(_M_ptr, __s._M_ptr);
1701 _M_refcount._M_swap(__s._M_refcount);
1707 _M_assign(_Tp* __ptr,
const __shared_count<_Lp>& __refcount) noexcept
1709 if (use_count() == 0)
1712 _M_refcount = __refcount;
1716 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1717 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1718 friend class __enable_shared_from_this<_Tp, _Lp>;
1719 friend class enable_shared_from_this<_Tp>;
1721 element_type* _M_ptr;
1722 __weak_count<_Lp> _M_refcount;
1726 template<
typename _Tp, _Lock_policy _Lp>
1728 swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
1731 template<
typename _Tp,
typename _Tp1>
1732 struct _Sp_owner_less :
public binary_function<_Tp, _Tp, bool>
1735 operator()(
const _Tp& __lhs,
const _Tp& __rhs)
const noexcept
1736 {
return __lhs.owner_before(__rhs); }
1739 operator()(
const _Tp& __lhs,
const _Tp1& __rhs)
const noexcept
1740 {
return __lhs.owner_before(__rhs); }
1743 operator()(
const _Tp1& __lhs,
const _Tp& __rhs)
const noexcept
1744 {
return __lhs.owner_before(__rhs); }
1748 struct _Sp_owner_less<void, void>
1750 template<
typename _Tp,
typename _Up>
1752 operator()(
const _Tp& __lhs,
const _Up& __rhs)
const noexcept
1753 -> decltype(__lhs.owner_before(__rhs))
1754 {
return __lhs.owner_before(__rhs); }
1756 using is_transparent = void;
1759 template<
typename _Tp, _Lock_policy _Lp>
1760 struct owner_less<__shared_ptr<_Tp, _Lp>>
1761 :
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
1764 template<
typename _Tp, _Lock_policy _Lp>
1765 struct owner_less<__weak_ptr<_Tp, _Lp>>
1766 :
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
1770 template<
typename _Tp, _Lock_policy _Lp>
1771 class __enable_shared_from_this
1774 constexpr __enable_shared_from_this() noexcept { }
1776 __enable_shared_from_this(
const __enable_shared_from_this&) noexcept { }
1778 __enable_shared_from_this&
1779 operator=(
const __enable_shared_from_this&) noexcept
1782 ~__enable_shared_from_this() { }
1785 __shared_ptr<_Tp, _Lp>
1787 {
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
1789 __shared_ptr<const _Tp, _Lp>
1790 shared_from_this()
const 1791 {
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
1793 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1794 __weak_ptr<_Tp, _Lp>
1795 weak_from_this() noexcept
1796 {
return this->_M_weak_this; }
1798 __weak_ptr<const _Tp, _Lp>
1799 weak_from_this() const noexcept
1800 {
return this->_M_weak_this; }
1804 template<
typename _Tp1>
1806 _M_weak_assign(_Tp1* __p,
const __shared_count<_Lp>& __n)
const noexcept
1807 { _M_weak_this._M_assign(__p, __n); }
1809 friend const __enable_shared_from_this*
1810 __enable_shared_from_this_base(
const __shared_count<_Lp>&,
1811 const __enable_shared_from_this* __p)
1814 template<
typename, _Lock_policy>
1815 friend class __shared_ptr;
1817 mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
1820 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1821 typename _Alloc,
typename... _Args>
1822 inline __shared_ptr<_Tp, _Lp>
1823 __allocate_shared(
const _Alloc& __a, _Args&&... __args)
1825 return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a},
1826 std::forward<_Args>(__args)...);
1829 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1831 inline __shared_ptr<_Tp, _Lp>
1832 __make_shared(_Args&&... __args)
1834 typedef typename std::remove_const<_Tp>::type _Tp_nc;
1836 std::forward<_Args>(__args)...);
1840 template<
typename _Tp, _Lock_policy _Lp>
1841 struct hash<__shared_ptr<_Tp, _Lp>>
1842 :
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
1845 operator()(
const __shared_ptr<_Tp, _Lp>& __s)
const noexcept
1852 _GLIBCXX_END_NAMESPACE_VERSION
1855 #endif // _SHARED_PTR_BASE_H
_GLIBCXX20_CONSTEXPR complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
Exception possibly thrown by shared_ptr.
ISO C++ entities toplevel namespace is std.
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
__shared_ptr< _Tp, _Lp > const_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
const_pointer_cast
Base class for all library exceptions.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
__shared_ptr< _Tp, _Lp > static_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
static_pointer_cast
The standard allocator, as per [20.4].
static auto construct(_Alloc &__a, _Tp *__p, _Args &&... __args) noexcept(noexcept(_S_construct(__a, __p, std::forward< _Args >(__args)...))) -> decltype(_S_construct(__a, __p, std::forward< _Args >(__args)...))
Construct an object of type _Tp.
Primary class template hash.
A simple smart pointer providing strict ownership semantics.
virtual char const * what() const noexcept
static void destroy(_Alloc &__a, _Tp *__p) noexcept(noexcept(_S_destroy(__a, __p, 0)))
Destroy an object of type _Tp.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
__allocated_ptr< _Alloc > __allocate_guarded(_Alloc &__a)
Allocate space for a single object using __a.
One of the comparison functors.
20.7.1.2 unique_ptr for single objects.
_Iterator __base(_Iterator __it)
__shared_ptr< _Tp, _Lp > dynamic_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
dynamic_pointer_cast