49 #ifndef _SHARED_PTR_BASE_H
50 #define _SHARED_PTR_BASE_H 1
63 #if __cplusplus > 201703L
67 namespace std _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_VERSION
71 #if _GLIBCXX_USE_DEPRECATED
72 #pragma GCC diagnostic push
73 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
75 #pragma GCC diagnostic pop
85 virtual char const*
what() const noexcept;
92 __throw_bad_weak_ptr()
95 using __gnu_cxx::_Lock_policy;
96 using __gnu_cxx::__default_lock_policy;
97 using __gnu_cxx::_S_single;
98 using __gnu_cxx::_S_mutex;
99 using __gnu_cxx::_S_atomic;
102 template<_Lock_policy _Lp>
107 enum { _S_need_barriers = 0 };
111 class _Mutex_base<_S_mutex>
112 :
public __gnu_cxx::__mutex
118 enum { _S_need_barriers = 1 };
121 template<_Lock_policy _Lp = __default_lock_policy>
122 class _Sp_counted_base
123 :
public _Mutex_base<_Lp>
126 _Sp_counted_base() noexcept
127 : _M_use_count(1), _M_weak_count(1) { }
130 ~_Sp_counted_base() noexcept
136 _M_dispose() noexcept = 0;
140 _M_destroy() noexcept
148 { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
153 if (!_M_add_ref_lock_nothrow())
154 __throw_bad_weak_ptr();
158 _M_add_ref_lock_nothrow() noexcept;
161 _M_release() noexcept
164 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
165 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
167 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count);
173 if (_Mutex_base<_Lp>::_S_need_barriers)
175 __atomic_thread_fence (__ATOMIC_ACQ_REL);
179 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
180 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
183 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
190 _M_weak_add_ref() noexcept
191 { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
194 _M_weak_release() noexcept
197 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
198 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
200 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
201 if (_Mutex_base<_Lp>::_S_need_barriers)
205 __atomic_thread_fence (__ATOMIC_ACQ_REL);
212 _M_get_use_count() const noexcept
216 return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
220 _Sp_counted_base(_Sp_counted_base
const&) =
delete;
221 _Sp_counted_base&
operator=(_Sp_counted_base
const&) =
delete;
223 _Atomic_word _M_use_count;
224 _Atomic_word _M_weak_count;
229 _Sp_counted_base<_S_single>::
230 _M_add_ref_lock_nothrow() noexcept
232 if (_M_use_count == 0)
240 _Sp_counted_base<_S_mutex>::
241 _M_add_ref_lock_nothrow() noexcept
244 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
254 _Sp_counted_base<_S_atomic>::
255 _M_add_ref_lock_nothrow() noexcept
258 _Atomic_word __count = _M_get_use_count();
266 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
267 true, __ATOMIC_ACQ_REL,
274 _Sp_counted_base<_S_single>::_M_add_ref_copy()
279 _Sp_counted_base<_S_single>::_M_release() noexcept
281 if (--_M_use_count == 0)
284 if (--_M_weak_count == 0)
291 _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
296 _Sp_counted_base<_S_single>::_M_weak_release() noexcept
298 if (--_M_weak_count == 0)
304 _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
305 {
return _M_use_count; }
309 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
312 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
315 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
316 class __enable_shared_from_this;
318 template<
typename _Tp>
321 template<
typename _Tp>
324 template<
typename _Tp>
327 template<
typename _Tp>
328 class enable_shared_from_this;
330 template<_Lock_policy _Lp = __default_lock_policy>
333 template<_Lock_policy _Lp = __default_lock_policy>
334 class __shared_count;
338 template<
typename _Ptr, _Lock_policy _Lp>
339 class _Sp_counted_ptr final :
public _Sp_counted_base<_Lp>
343 _Sp_counted_ptr(_Ptr __p) noexcept
347 _M_dispose() noexcept
351 _M_destroy() noexcept
358 _Sp_counted_ptr(
const _Sp_counted_ptr&) =
delete;
359 _Sp_counted_ptr&
operator=(
const _Sp_counted_ptr&) =
delete;
367 _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
371 _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
375 _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
377 template<
int _Nm,
typename _Tp,
378 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
379 struct _Sp_ebo_helper;
382 template<
int _Nm,
typename _Tp>
383 struct _Sp_ebo_helper<_Nm, _Tp, true> :
private _Tp
385 explicit _Sp_ebo_helper(
const _Tp& __tp) : _Tp(__tp) { }
386 explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(
std::move(__tp)) { }
389 _S_get(_Sp_ebo_helper& __eboh) {
return static_cast<_Tp&
>(__eboh); }
393 template<
int _Nm,
typename _Tp>
394 struct _Sp_ebo_helper<_Nm, _Tp, false>
396 explicit _Sp_ebo_helper(
const _Tp& __tp) : _M_tp(__tp) { }
397 explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(
std::move(__tp)) { }
400 _S_get(_Sp_ebo_helper& __eboh)
401 {
return __eboh._M_tp; }
408 template<
typename _Ptr,
typename _Deleter,
typename _Alloc, _Lock_policy _Lp>
409 class _Sp_counted_deleter final :
public _Sp_counted_base<_Lp>
411 class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc>
413 typedef _Sp_ebo_helper<0, _Deleter> _Del_base;
414 typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base;
417 _Impl(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
418 : _Del_base(
std::move(__d)), _Alloc_base(__a), _M_ptr(__p)
421 _Deleter& _M_del() noexcept {
return _Del_base::_S_get(*
this); }
422 _Alloc& _M_alloc() noexcept {
return _Alloc_base::_S_get(*
this); }
428 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;
431 _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept
432 : _M_impl(__p,
std::move(__d), _Alloc()) { }
435 _Sp_counted_deleter(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
438 ~_Sp_counted_deleter() noexcept { }
441 _M_dispose() noexcept
442 { _M_impl._M_del()(_M_impl._M_ptr); }
445 _M_destroy() noexcept
447 __allocator_type __a(_M_impl._M_alloc());
448 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
449 this->~_Sp_counted_deleter();
453 _M_get_deleter(
const type_info& __ti [[__gnu__::__unused__]]) noexcept
458 return __ti ==
typeid(_Deleter)
472 struct _Sp_make_shared_tag
475 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
476 friend class _Sp_counted_ptr_inplace;
478 static const type_info&
479 _S_ti() noexcept _GLIBCXX_VISIBILITY(default)
481 alignas(type_info)
static constexpr
char __tag[
sizeof(type_info)] = { };
482 return reinterpret_cast<const type_info&
>(__tag);
485 static bool _S_eq(
const type_info&) noexcept;
488 template<
typename _Alloc>
489 struct _Sp_alloc_shared_tag
494 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
495 class _Sp_counted_ptr_inplace final :
public _Sp_counted_base<_Lp>
497 class _Impl : _Sp_ebo_helper<0, _Alloc>
499 typedef _Sp_ebo_helper<0, _Alloc> _A_base;
502 explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { }
504 _Alloc& _M_alloc() noexcept {
return _A_base::_S_get(*
this); }
506 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
510 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
513 template<
typename... _Args>
514 _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
520 std::forward<_Args>(__args)...);
523 ~_Sp_counted_ptr_inplace() noexcept { }
526 _M_dispose() noexcept
533 _M_destroy() noexcept
535 __allocator_type __a(_M_impl._M_alloc());
536 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
537 this->~_Sp_counted_ptr_inplace();
541 friend class __shared_count<_Lp>;
548 auto __ptr =
const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
553 if (&__ti == &_Sp_make_shared_tag::_S_ti()
556 __ti ==
typeid(_Sp_make_shared_tag)
558 _Sp_make_shared_tag::_S_eq(__ti)
565 _Tp* _M_ptr() noexcept {
return _M_impl._M_storage._M_ptr(); }
571 struct __sp_array_delete
573 template<
typename _Yp>
574 void operator()(_Yp* __p)
const {
delete[] __p; }
577 template<_Lock_policy _Lp>
580 template<
typename _Tp>
581 struct __not_alloc_shared_tag {
using type = void; };
583 template<
typename _Tp>
584 struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { };
587 constexpr __shared_count() noexcept : _M_pi(0)
590 template<
typename _Ptr>
592 __shared_count(_Ptr __p) : _M_pi(0)
596 _M_pi =
new _Sp_counted_ptr<_Ptr, _Lp>(__p);
601 __throw_exception_again;
605 template<
typename _Ptr>
607 : __shared_count(__p)
610 template<
typename _Ptr>
612 : __shared_count(__p, __sp_array_delete{}, allocator<void>())
615 template<
typename _Ptr,
typename _Deleter,
616 typename =
typename __not_alloc_shared_tag<_Deleter>::type>
617 __shared_count(_Ptr __p, _Deleter __d)
618 : __shared_count(__p,
std::
move(__d), allocator<void>())
621 template<
typename _Ptr,
typename _Deleter,
typename _Alloc,
622 typename =
typename __not_alloc_shared_tag<_Deleter>::type>
623 __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0)
625 typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type;
628 typename _Sp_cd_type::__allocator_type __a2(__a);
630 _Sp_cd_type* __mem = __guard.get();
638 __throw_exception_again;
642 template<
typename _Tp,
typename _Alloc,
typename... _Args>
643 __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a,
646 typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
647 typename _Sp_cp_type::__allocator_type __a2(__a._M_a);
649 _Sp_cp_type* __mem = __guard.get();
650 auto __pi = ::new (__mem)
651 _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
654 __p = __pi->_M_ptr();
657 #if _GLIBCXX_USE_DEPRECATED
658 #pragma GCC diagnostic push
659 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
661 template<
typename _Tp>
664 #pragma GCC diagnostic pop
668 template<
typename _Tp,
typename _Del>
674 if (__r.get() ==
nullptr)
677 using _Ptr =
typename unique_ptr<_Tp, _Del>::pointer;
678 using _Del2 =
typename conditional<is_reference<_Del>::value,
679 reference_wrapper<typename remove_reference<_Del>::type>,
682 = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
683 using _Alloc = allocator<_Sp_cd_type>;
684 using _Alloc_traits = allocator_traits<_Alloc>;
686 _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1);
687 _Alloc_traits::construct(__a, __mem, __r.release(),
693 explicit __shared_count(
const __weak_count<_Lp>& __r);
697 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t) noexcept;
699 ~__shared_count() noexcept
701 if (_M_pi !=
nullptr)
705 __shared_count(
const __shared_count& __r) noexcept
708 if (_M_pi !=
nullptr)
709 _M_pi->_M_add_ref_copy();
713 operator=(
const __shared_count& __r) noexcept
715 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
718 if (__tmp !=
nullptr)
719 __tmp->_M_add_ref_copy();
720 if (_M_pi !=
nullptr)
728 _M_swap(__shared_count& __r) noexcept
730 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
736 _M_get_use_count() const noexcept
737 {
return _M_pi ? _M_pi->_M_get_use_count() : 0; }
740 _M_unique() const noexcept
741 {
return this->_M_get_use_count() == 1; }
745 {
return _M_pi ? _M_pi->_M_get_deleter(__ti) :
nullptr; }
748 _M_less(
const __shared_count& __rhs)
const noexcept
752 _M_less(
const __weak_count<_Lp>& __rhs)
const noexcept
757 operator==(
const __shared_count& __a,
const __shared_count& __b) noexcept
758 {
return __a._M_pi == __b._M_pi; }
761 friend class __weak_count<_Lp>;
763 _Sp_counted_base<_Lp>* _M_pi;
767 template<_Lock_policy _Lp>
771 constexpr __weak_count() noexcept : _M_pi(
nullptr)
774 __weak_count(
const __shared_count<_Lp>& __r) noexcept
777 if (_M_pi !=
nullptr)
778 _M_pi->_M_weak_add_ref();
781 __weak_count(
const __weak_count& __r) noexcept
784 if (_M_pi !=
nullptr)
785 _M_pi->_M_weak_add_ref();
788 __weak_count(__weak_count&& __r) noexcept
790 { __r._M_pi =
nullptr; }
792 ~__weak_count() noexcept
794 if (_M_pi !=
nullptr)
795 _M_pi->_M_weak_release();
799 operator=(
const __shared_count<_Lp>& __r) noexcept
801 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
802 if (__tmp !=
nullptr)
803 __tmp->_M_weak_add_ref();
804 if (_M_pi !=
nullptr)
805 _M_pi->_M_weak_release();
811 operator=(
const __weak_count& __r) noexcept
813 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
814 if (__tmp !=
nullptr)
815 __tmp->_M_weak_add_ref();
816 if (_M_pi !=
nullptr)
817 _M_pi->_M_weak_release();
825 if (_M_pi !=
nullptr)
826 _M_pi->_M_weak_release();
833 _M_swap(__weak_count& __r) noexcept
835 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
841 _M_get_use_count() const noexcept
842 {
return _M_pi !=
nullptr ? _M_pi->_M_get_use_count() : 0; }
845 _M_less(
const __weak_count& __rhs)
const noexcept
849 _M_less(
const __shared_count<_Lp>& __rhs)
const noexcept
854 operator==(
const __weak_count& __a,
const __weak_count& __b) noexcept
855 {
return __a._M_pi == __b._M_pi; }
858 friend class __shared_count<_Lp>;
860 _Sp_counted_base<_Lp>* _M_pi;
864 template<_Lock_policy _Lp>
866 __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
869 if (_M_pi ==
nullptr || !_M_pi->_M_add_ref_lock_nothrow())
870 __throw_bad_weak_ptr();
874 template<_Lock_policy _Lp>
876 __shared_count<_Lp>::
877 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t) noexcept
880 if (_M_pi && !_M_pi->_M_add_ref_lock_nothrow())
884 #define __cpp_lib_shared_ptr_arrays 201611L
890 template<
typename _Yp_ptr,
typename _Tp_ptr>
891 struct __sp_compatible_with
895 template<
typename _Yp,
typename _Tp>
896 struct __sp_compatible_with<_Yp*, _Tp*>
897 : is_convertible<_Yp*, _Tp*>::type
900 template<
typename _Up,
size_t _Nm>
901 struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
905 template<
typename _Up,
size_t _Nm>
906 struct __sp_compatible_with<_Up(*)[_Nm],
const _Up(*)[]>
910 template<
typename _Up,
size_t _Nm>
911 struct __sp_compatible_with<_Up(*)[_Nm],
volatile _Up(*)[]>
915 template<
typename _Up,
size_t _Nm>
916 struct __sp_compatible_with<_Up(*)[_Nm],
const volatile _Up(*)[]>
921 template<
typename _Up,
size_t _Nm,
typename _Yp,
typename =
void>
922 struct __sp_is_constructible_arrN
926 template<
typename _Up,
size_t _Nm,
typename _Yp>
927 struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
928 : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
932 template<
typename _Up,
typename _Yp,
typename =
void>
933 struct __sp_is_constructible_arr
937 template<
typename _Up,
typename _Yp>
938 struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
939 : is_convertible<_Yp(*)[], _Up(*)[]>::type
943 template<
typename _Tp,
typename _Yp>
944 struct __sp_is_constructible;
947 template<
typename _Up,
size_t _Nm,
typename _Yp>
948 struct __sp_is_constructible<_Up[_Nm], _Yp>
949 : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
953 template<
typename _Up,
typename _Yp>
954 struct __sp_is_constructible<_Up[], _Yp>
955 : __sp_is_constructible_arr<_Up, _Yp>::type
959 template<
typename _Tp,
typename _Yp>
960 struct __sp_is_constructible
961 : is_convertible<_Yp*, _Tp*>::type
966 template<
typename _Tp, _Lock_policy _Lp,
967 bool = is_array<_Tp>::value,
bool = is_void<_Tp>::value>
968 class __shared_ptr_access
976 __glibcxx_assert(_M_get() !=
nullptr);
983 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
989 _M_get() const noexcept
990 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
994 template<
typename _Tp, _Lock_policy _Lp>
995 class __shared_ptr_access<_Tp, _Lp, false, true>
1003 auto __ptr =
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get();
1004 _GLIBCXX_DEBUG_PEDASSERT(__ptr !=
nullptr);
1010 template<
typename _Tp, _Lock_policy _Lp>
1011 class __shared_ptr_access<_Tp, _Lp, true, false>
1014 using element_type =
typename remove_extent<_Tp>::type;
1016 #if __cplusplus <= 201402L
1017 [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
1021 __glibcxx_assert(_M_get() !=
nullptr);
1025 [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
1029 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1035 operator[](ptrdiff_t __i)
const
1037 __glibcxx_assert(_M_get() !=
nullptr);
1038 __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
1039 return _M_get()[__i];
1044 _M_get() const noexcept
1045 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
1048 template<
typename _Tp, _Lock_policy _Lp>
1050 :
public __shared_ptr_access<_Tp, _Lp>
1053 using element_type =
typename remove_extent<_Tp>::type;
1057 template<
typename _Yp>
1059 =
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
1062 template<
typename _Yp,
typename _Res =
void>
1063 using _Compatible =
typename
1064 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1067 template<
typename _Yp>
1068 using _Assignable = _Compatible<_Yp, __shared_ptr&>;
1071 template<
typename _Yp,
typename _Del,
typename _Res = void,
1072 typename _Ptr =
typename unique_ptr<_Yp, _Del>::pointer>
1073 using _UniqCompatible =
typename enable_if<__and_<
1074 __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
1075 >::value, _Res>::type;
1078 template<
typename _Yp,
typename _Del>
1079 using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
1083 #if __cplusplus > 201402L
1084 using weak_type = __weak_ptr<_Tp, _Lp>;
1087 constexpr __shared_ptr() noexcept
1088 : _M_ptr(0), _M_refcount()
1091 template<
typename _Yp,
typename = _SafeConv<_Yp>>
1093 __shared_ptr(_Yp* __p)
1094 : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
1096 static_assert( !is_void<_Yp>::value,
"incomplete type" );
1097 static_assert(
sizeof(_Yp) > 0,
"incomplete type" );
1098 _M_enable_shared_from_this_with(__p);
1101 template<
typename _Yp,
typename _Deleter,
typename = _SafeConv<_Yp>>
1102 __shared_ptr(_Yp* __p, _Deleter __d)
1103 : _M_ptr(__p), _M_refcount(__p,
std::
move(__d))
1105 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1106 "deleter expression d(p) is well-formed");
1107 _M_enable_shared_from_this_with(__p);
1110 template<
typename _Yp,
typename _Deleter,
typename _Alloc,
1111 typename = _SafeConv<_Yp>>
1112 __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
1115 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1116 "deleter expression d(p) is well-formed");
1117 _M_enable_shared_from_this_with(__p);
1120 template<
typename _Deleter>
1121 __shared_ptr(nullptr_t __p, _Deleter __d)
1122 : _M_ptr(0), _M_refcount(__p,
std::
move(__d))
1125 template<
typename _Deleter,
typename _Alloc>
1126 __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
1131 template<
typename _Yp>
1132 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
1134 : _M_ptr(__p), _M_refcount(__r._M_refcount)
1138 template<
typename _Yp>
1139 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r,
1141 : _M_ptr(__p), _M_refcount()
1143 _M_refcount._M_swap(__r._M_refcount);
1144 __r._M_ptr =
nullptr;
1147 __shared_ptr(
const __shared_ptr&) noexcept =
default;
1148 __shared_ptr&
operator=(
const __shared_ptr&) noexcept =
default;
1149 ~__shared_ptr() =
default;
1151 template<
typename _Yp,
typename = _Compatible<_Yp>>
1152 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1153 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1156 __shared_ptr(__shared_ptr&& __r) noexcept
1157 : _M_ptr(__r._M_ptr), _M_refcount()
1159 _M_refcount._M_swap(__r._M_refcount);
1160 __r._M_ptr =
nullptr;
1163 template<
typename _Yp,
typename = _Compatible<_Yp>>
1164 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1165 : _M_ptr(__r._M_ptr), _M_refcount()
1167 _M_refcount._M_swap(__r._M_refcount);
1168 __r._M_ptr =
nullptr;
1171 template<
typename _Yp,
typename = _Compatible<_Yp>>
1172 explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
1173 : _M_refcount(__r._M_refcount)
1177 _M_ptr = __r._M_ptr;
1181 template<
typename _Yp,
typename _Del,
1182 typename = _UniqCompatible<_Yp, _Del>>
1183 __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
1184 : _M_ptr(__r.get()), _M_refcount()
1186 auto __raw = __to_address(__r.get());
1187 _M_refcount = __shared_count<_Lp>(
std::move(__r));
1188 _M_enable_shared_from_this_with(__raw);
1191 #if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED
1194 template<
typename _Tp1,
typename _Del,
1195 typename enable_if<__and_<
1196 __not_<is_array<_Tp>>, is_array<_Tp1>,
1197 is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
1198 >::value,
bool>::type =
true>
1199 __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
1200 : _M_ptr(__r.get()), _M_refcount()
1202 auto __raw = __to_address(__r.get());
1203 _M_refcount = __shared_count<_Lp>(
std::move(__r));
1204 _M_enable_shared_from_this_with(__raw);
1209 #if _GLIBCXX_USE_DEPRECATED
1210 #pragma GCC diagnostic push
1211 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1213 template<
typename _Yp,
typename = _Compatible<_Yp>>
1214 __shared_ptr(auto_ptr<_Yp>&& __r);
1215 #pragma GCC diagnostic pop
1218 constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
1220 template<
typename _Yp>
1222 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1224 _M_ptr = __r._M_ptr;
1225 _M_refcount = __r._M_refcount;
1229 #if _GLIBCXX_USE_DEPRECATED
1230 #pragma GCC diagnostic push
1231 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1232 template<
typename _Yp>
1236 __shared_ptr(
std::move(__r)).swap(*
this);
1239 #pragma GCC diagnostic pop
1245 __shared_ptr(
std::move(__r)).swap(*
this);
1251 operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1253 __shared_ptr(
std::move(__r)).swap(*
this);
1257 template<
typename _Yp,
typename _Del>
1258 _UniqAssignable<_Yp, _Del>
1261 __shared_ptr(
std::move(__r)).swap(*
this);
1267 { __shared_ptr().swap(*
this); }
1269 template<
typename _Yp>
1274 __glibcxx_assert(__p ==
nullptr || __p != _M_ptr);
1275 __shared_ptr(__p).swap(*
this);
1278 template<
typename _Yp,
typename _Deleter>
1280 reset(_Yp* __p, _Deleter __d)
1281 { __shared_ptr(__p,
std::move(__d)).swap(*
this); }
1283 template<
typename _Yp,
typename _Deleter,
typename _Alloc>
1285 reset(_Yp* __p, _Deleter __d, _Alloc __a)
1290 get() const noexcept
1294 explicit operator bool() const noexcept
1295 {
return _M_ptr !=
nullptr; }
1299 unique() const noexcept
1300 {
return _M_refcount._M_unique(); }
1304 use_count() const noexcept
1305 {
return _M_refcount._M_get_use_count(); }
1309 swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
1312 _M_refcount._M_swap(__other._M_refcount);
1322 template<
typename _Tp1>
1324 owner_before(__shared_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1325 {
return _M_refcount._M_less(__rhs._M_refcount); }
1327 template<
typename _Tp1>
1329 owner_before(__weak_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1330 {
return _M_refcount._M_less(__rhs._M_refcount); }
1335 template<
typename _Alloc,
typename... _Args>
1336 __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
1337 : _M_ptr(), _M_refcount(_M_ptr, __tag,
std::
forward<_Args>(__args)...)
1338 { _M_enable_shared_from_this_with(_M_ptr); }
1340 template<
typename _Tp1, _Lock_policy _Lp1,
typename _Alloc,
1342 friend __shared_ptr<_Tp1, _Lp1>
1343 __allocate_shared(
const _Alloc& __a, _Args&&... __args);
1347 __shared_ptr(
const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t) noexcept
1348 : _M_refcount(__r._M_refcount, std::nothrow)
1350 _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr :
nullptr;
1353 friend class __weak_ptr<_Tp, _Lp>;
1357 template<
typename _Yp>
1358 using __esft_base_t = decltype(__enable_shared_from_this_base(
1359 std::declval<
const __shared_count<_Lp>&>(),
1360 std::declval<_Yp*>()));
1363 template<
typename _Yp,
typename =
void>
1364 struct __has_esft_base
1367 template<
typename _Yp>
1368 struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
1369 : __not_<is_array<_Tp>> { };
1371 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1372 typename enable_if<__has_esft_base<_Yp2>::value>::type
1373 _M_enable_shared_from_this_with(_Yp* __p) noexcept
1375 if (
auto __base = __enable_shared_from_this_base(_M_refcount, __p))
1376 __base->_M_weak_assign(
const_cast<_Yp2*
>(__p), _M_refcount);
1379 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1380 typename enable_if<!__has_esft_base<_Yp2>::value>::type
1381 _M_enable_shared_from_this_with(_Yp*) noexcept
1386 {
return _M_refcount._M_get_deleter(__ti); }
1388 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1389 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1391 template<
typename _Del,
typename _Tp1, _Lock_policy _Lp1>
1392 friend _Del* get_deleter(
const __shared_ptr<_Tp1, _Lp1>&) noexcept;
1394 template<
typename _Del,
typename _Tp1>
1395 friend _Del* get_deleter(
const shared_ptr<_Tp1>&) noexcept;
1398 __shared_count<_Lp> _M_refcount;
1403 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1405 operator==(
const __shared_ptr<_Tp1, _Lp>& __a,
1406 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1407 {
return __a.get() == __b.get(); }
1409 template<
typename _Tp, _Lock_policy _Lp>
1411 operator==(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1414 #ifdef __cpp_lib_three_way_comparison
1415 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1416 inline strong_ordering
1417 operator<=>(
const __shared_ptr<_Tp, _Lp>& __a,
1418 const __shared_ptr<_Up, _Lp>& __b) noexcept
1419 {
return compare_three_way()(__a.get(), __b.get()); }
1421 template<
typename _Tp, _Lock_policy _Lp>
1422 inline strong_ordering
1423 operator<=>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1426 return compare_three_way()(__a.get(),
static_cast<pointer
>(
nullptr));
1429 template<
typename _Tp, _Lock_policy _Lp>
1431 operator==(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1434 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1436 operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
1437 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1438 {
return __a.get() != __b.get(); }
1440 template<
typename _Tp, _Lock_policy _Lp>
1442 operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1443 {
return (
bool)__a; }
1445 template<
typename _Tp, _Lock_policy _Lp>
1447 operator!=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1448 {
return (
bool)__a; }
1450 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1452 operator<(
const __shared_ptr<_Tp, _Lp>& __a,
1453 const __shared_ptr<_Up, _Lp>& __b) noexcept
1457 using _Vp =
typename common_type<_Tp_elt*, _Up_elt*>::type;
1458 return less<_Vp>()(__a.get(), __b.get());
1461 template<
typename _Tp, _Lock_policy _Lp>
1463 operator<(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1466 return less<_Tp_elt*>()(__a.get(),
nullptr);
1469 template<
typename _Tp, _Lock_policy _Lp>
1471 operator<(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1474 return less<_Tp_elt*>()(
nullptr, __a.get());
1477 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1479 operator<=(
const __shared_ptr<_Tp1, _Lp>& __a,
1480 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1481 {
return !(__b < __a); }
1483 template<
typename _Tp, _Lock_policy _Lp>
1485 operator<=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1486 {
return !(
nullptr < __a); }
1488 template<
typename _Tp, _Lock_policy _Lp>
1490 operator<=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1491 {
return !(__a <
nullptr); }
1493 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1495 operator>(
const __shared_ptr<_Tp1, _Lp>& __a,
1496 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1497 {
return (__b < __a); }
1499 template<
typename _Tp, _Lock_policy _Lp>
1501 operator>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1502 {
return nullptr < __a; }
1504 template<
typename _Tp, _Lock_policy _Lp>
1506 operator>(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1507 {
return __a <
nullptr; }
1509 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1511 operator>=(
const __shared_ptr<_Tp1, _Lp>& __a,
1512 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1513 {
return !(__a < __b); }
1515 template<
typename _Tp, _Lock_policy _Lp>
1517 operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1518 {
return !(__a <
nullptr); }
1520 template<
typename _Tp, _Lock_policy _Lp>
1522 operator>=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1523 {
return !(
nullptr < __a); }
1527 template<
typename _Tp, _Lock_policy _Lp>
1529 swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
1539 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1540 inline __shared_ptr<_Tp, _Lp>
1543 using _Sp = __shared_ptr<_Tp, _Lp>;
1552 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1553 inline __shared_ptr<_Tp, _Lp>
1556 using _Sp = __shared_ptr<_Tp, _Lp>;
1565 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1566 inline __shared_ptr<_Tp, _Lp>
1569 using _Sp = __shared_ptr<_Tp, _Lp>;
1571 return _Sp(__r, __p);
1575 #if __cplusplus > 201402L
1576 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1577 inline __shared_ptr<_Tp, _Lp>
1578 reinterpret_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1580 using _Sp = __shared_ptr<_Tp, _Lp>;
1585 template<
typename _Tp, _Lock_policy _Lp>
1588 template<
typename _Yp,
typename _Res =
void>
1589 using _Compatible =
typename
1590 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1593 template<
typename _Yp>
1594 using _Assignable = _Compatible<_Yp, __weak_ptr&>;
1597 using element_type =
typename remove_extent<_Tp>::type;
1599 constexpr __weak_ptr() noexcept
1600 : _M_ptr(
nullptr), _M_refcount()
1603 __weak_ptr(
const __weak_ptr&) noexcept =
default;
1605 ~__weak_ptr() =
default;
1621 template<
typename _Yp,
typename = _Compatible<_Yp>>
1622 __weak_ptr(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1623 : _M_refcount(__r._M_refcount)
1624 { _M_ptr = __r.lock().get(); }
1626 template<
typename _Yp,
typename = _Compatible<_Yp>>
1627 __weak_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1628 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1631 __weak_ptr(__weak_ptr&& __r) noexcept
1632 : _M_ptr(__r._M_ptr), _M_refcount(
std::move(__r._M_refcount))
1633 { __r._M_ptr =
nullptr; }
1635 template<
typename _Yp,
typename = _Compatible<_Yp>>
1636 __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1637 : _M_ptr(__r.lock().get()), _M_refcount(
std::move(__r._M_refcount))
1638 { __r._M_ptr =
nullptr; }
1641 operator=(
const __weak_ptr& __r) noexcept =
default;
1643 template<
typename _Yp>
1645 operator=(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1647 _M_ptr = __r.lock().get();
1648 _M_refcount = __r._M_refcount;
1652 template<
typename _Yp>
1654 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1656 _M_ptr = __r._M_ptr;
1657 _M_refcount = __r._M_refcount;
1664 _M_ptr = __r._M_ptr;
1665 _M_refcount =
std::move(__r._M_refcount);
1666 __r._M_ptr =
nullptr;
1670 template<
typename _Yp>
1672 operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1674 _M_ptr = __r.lock().get();
1675 _M_refcount =
std::move(__r._M_refcount);
1676 __r._M_ptr =
nullptr;
1680 __shared_ptr<_Tp, _Lp>
1681 lock() const noexcept
1682 {
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
1685 use_count() const noexcept
1686 {
return _M_refcount._M_get_use_count(); }
1689 expired() const noexcept
1690 {
return _M_refcount._M_get_use_count() == 0; }
1692 template<
typename _Tp1>
1694 owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1695 {
return _M_refcount._M_less(__rhs._M_refcount); }
1697 template<
typename _Tp1>
1699 owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1700 {
return _M_refcount._M_less(__rhs._M_refcount); }
1704 { __weak_ptr().swap(*
this); }
1707 swap(__weak_ptr& __s) noexcept
1710 _M_refcount._M_swap(__s._M_refcount);
1716 _M_assign(_Tp* __ptr,
const __shared_count<_Lp>& __refcount) noexcept
1718 if (use_count() == 0)
1721 _M_refcount = __refcount;
1725 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1726 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1727 friend class __enable_shared_from_this<_Tp, _Lp>;
1728 friend class enable_shared_from_this<_Tp>;
1731 __weak_count<_Lp> _M_refcount;
1735 template<
typename _Tp, _Lock_policy _Lp>
1737 swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
1740 template<
typename _Tp,
typename _Tp1>
1741 struct _Sp_owner_less :
public binary_function<_Tp, _Tp, bool>
1744 operator()(
const _Tp& __lhs,
const _Tp& __rhs)
const noexcept
1745 {
return __lhs.owner_before(__rhs); }
1748 operator()(
const _Tp& __lhs,
const _Tp1& __rhs)
const noexcept
1749 {
return __lhs.owner_before(__rhs); }
1752 operator()(
const _Tp1& __lhs,
const _Tp& __rhs)
const noexcept
1753 {
return __lhs.owner_before(__rhs); }
1757 struct _Sp_owner_less<void, void>
1759 template<
typename _Tp,
typename _Up>
1761 operator()(
const _Tp& __lhs,
const _Up& __rhs)
const noexcept
1762 -> decltype(__lhs.owner_before(__rhs))
1763 {
return __lhs.owner_before(__rhs); }
1765 using is_transparent = void;
1768 template<
typename _Tp, _Lock_policy _Lp>
1769 struct owner_less<__shared_ptr<_Tp, _Lp>>
1770 :
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
1773 template<
typename _Tp, _Lock_policy _Lp>
1774 struct owner_less<__weak_ptr<_Tp, _Lp>>
1775 :
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
1779 template<
typename _Tp, _Lock_policy _Lp>
1780 class __enable_shared_from_this
1783 constexpr __enable_shared_from_this() noexcept { }
1785 __enable_shared_from_this(
const __enable_shared_from_this&) noexcept { }
1787 __enable_shared_from_this&
1788 operator=(
const __enable_shared_from_this&) noexcept
1791 ~__enable_shared_from_this() { }
1794 __shared_ptr<_Tp, _Lp>
1796 {
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
1798 __shared_ptr<const _Tp, _Lp>
1799 shared_from_this()
const
1800 {
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
1802 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1803 __weak_ptr<_Tp, _Lp>
1804 weak_from_this() noexcept
1805 {
return this->_M_weak_this; }
1807 __weak_ptr<const _Tp, _Lp>
1808 weak_from_this() const noexcept
1809 {
return this->_M_weak_this; }
1813 template<
typename _Tp1>
1815 _M_weak_assign(_Tp1* __p,
const __shared_count<_Lp>& __n)
const noexcept
1816 { _M_weak_this._M_assign(__p, __n); }
1818 friend const __enable_shared_from_this*
1819 __enable_shared_from_this_base(
const __shared_count<_Lp>&,
1820 const __enable_shared_from_this* __p)
1823 template<
typename, _Lock_policy>
1824 friend class __shared_ptr;
1826 mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
1829 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1830 typename _Alloc,
typename... _Args>
1831 inline __shared_ptr<_Tp, _Lp>
1832 __allocate_shared(
const _Alloc& __a, _Args&&... __args)
1834 return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a},
1835 std::forward<_Args>(__args)...);
1838 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1840 inline __shared_ptr<_Tp, _Lp>
1841 __make_shared(_Args&&... __args)
1843 typedef typename std::remove_const<_Tp>::type _Tp_nc;
1845 std::forward<_Args>(__args)...);
1849 template<
typename _Tp, _Lock_policy _Lp>
1850 struct hash<__shared_ptr<_Tp, _Lp>>
1851 :
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
1854 operator()(
const __shared_ptr<_Tp, _Lp>& __s)
const noexcept
1861 _GLIBCXX_END_NAMESPACE_VERSION
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
void reset(element_type *__p=0)
Forcibly deletes the managed object.
element_type * operator->() const
Smart pointer dereferencing.
auto_ptr(element_type *__p=0)
An auto_ptr is usually constructed from a raw pointer.
_Tp element_type
The pointed-to type.
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
ISO C++ entities toplevel namespace is std.
__allocated_ptr< _Alloc > __allocate_guarded(_Alloc &__a)
Allocate space for a single object using __a.
__shared_ptr< _Tp, _Lp > static_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
static_pointer_cast
__shared_ptr< _Tp, _Lp > const_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
const_pointer_cast
__shared_ptr< _Tp, _Lp > dynamic_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
dynamic_pointer_cast
constexpr _Iterator __base(_Iterator __it)
Primary class template hash.
static constexpr 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.
static constexpr void destroy(_Alloc &__a, _Tp *__p) noexcept(noexcept(_S_destroy(__a, __p, 0)))
Destroy an object of type _Tp.
The standard allocator, as per [20.4].
Base class for all library exceptions.
Exception possibly thrown by shared_ptr.
virtual char const * what() const noexcept
One of the comparison functors.
20.7.1.2 unique_ptr for single objects.
A simple smart pointer providing strict ownership semantics.