49#ifndef _SHARED_PTR_BASE_H
50#define _SHARED_PTR_BASE_H 1
63#if __cplusplus > 201703L
67namespace 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"
74 template<
typename>
class auto_ptr;
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)
519 allocator_traits<_Alloc>::construct(__a, _M_ptr(),
520 std::forward<_Args>(__args)...);
523 ~_Sp_counted_ptr_inplace() noexcept { }
526 _M_dispose() noexcept
528 allocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr());
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>
606 __shared_count(_Ptr __p, false_type)
607 : __shared_count(__p)
610 template<
typename _Ptr>
611 __shared_count(_Ptr __p, true_type)
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);
629 auto __guard = std::__allocate_guarded(__a2);
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);
648 auto __guard = std::__allocate_guarded(__a2);
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);
690 _Alloc_traits::construct(__a, __mem, __r.release(),
691 std::forward<_Del>(__r.get_deleter()));
696 explicit __shared_count(
const __weak_count<_Lp>& __r);
700 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t)
noexcept;
702 ~__shared_count() noexcept
704 if (_M_pi !=
nullptr)
708 __shared_count(
const __shared_count& __r) noexcept
711 if (_M_pi !=
nullptr)
712 _M_pi->_M_add_ref_copy();
716 operator=(
const __shared_count& __r)
noexcept
718 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
721 if (__tmp !=
nullptr)
722 __tmp->_M_add_ref_copy();
723 if (_M_pi !=
nullptr)
731 _M_swap(__shared_count& __r)
noexcept
733 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
739 _M_get_use_count() const noexcept
740 {
return _M_pi ? _M_pi->_M_get_use_count() : 0; }
743 _M_unique() const noexcept
744 {
return this->_M_get_use_count() == 1; }
748 {
return _M_pi ? _M_pi->_M_get_deleter(__ti) :
nullptr; }
751 _M_less(
const __shared_count& __rhs)
const noexcept
755 _M_less(
const __weak_count<_Lp>& __rhs)
const noexcept
760 operator==(
const __shared_count& __a,
const __shared_count& __b)
noexcept
761 {
return __a._M_pi == __b._M_pi; }
764 friend class __weak_count<_Lp>;
766 _Sp_counted_base<_Lp>* _M_pi;
770 template<_Lock_policy _Lp>
774 constexpr __weak_count() noexcept : _M_pi(
nullptr)
777 __weak_count(
const __shared_count<_Lp>& __r) noexcept
780 if (_M_pi !=
nullptr)
781 _M_pi->_M_weak_add_ref();
784 __weak_count(
const __weak_count& __r) noexcept
787 if (_M_pi !=
nullptr)
788 _M_pi->_M_weak_add_ref();
791 __weak_count(__weak_count&& __r) noexcept
793 { __r._M_pi =
nullptr; }
795 ~__weak_count() noexcept
797 if (_M_pi !=
nullptr)
798 _M_pi->_M_weak_release();
802 operator=(
const __shared_count<_Lp>& __r)
noexcept
804 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
805 if (__tmp !=
nullptr)
806 __tmp->_M_weak_add_ref();
807 if (_M_pi !=
nullptr)
808 _M_pi->_M_weak_release();
814 operator=(
const __weak_count& __r)
noexcept
816 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
817 if (__tmp !=
nullptr)
818 __tmp->_M_weak_add_ref();
819 if (_M_pi !=
nullptr)
820 _M_pi->_M_weak_release();
826 operator=(__weak_count&& __r)
noexcept
828 if (_M_pi !=
nullptr)
829 _M_pi->_M_weak_release();
836 _M_swap(__weak_count& __r)
noexcept
838 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
844 _M_get_use_count() const noexcept
845 {
return _M_pi !=
nullptr ? _M_pi->_M_get_use_count() : 0; }
848 _M_less(
const __weak_count& __rhs)
const noexcept
852 _M_less(
const __shared_count<_Lp>& __rhs)
const noexcept
857 operator==(
const __weak_count& __a,
const __weak_count& __b)
noexcept
858 {
return __a._M_pi == __b._M_pi; }
861 friend class __shared_count<_Lp>;
863 _Sp_counted_base<_Lp>* _M_pi;
867 template<_Lock_policy _Lp>
869 __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
872 if (_M_pi ==
nullptr || !_M_pi->_M_add_ref_lock_nothrow())
873 __throw_bad_weak_ptr();
877 template<_Lock_policy _Lp>
879 __shared_count<_Lp>::
880 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t) noexcept
883 if (_M_pi && !_M_pi->_M_add_ref_lock_nothrow())
887#define __cpp_lib_shared_ptr_arrays 201611L
893 template<
typename _Yp_ptr,
typename _Tp_ptr>
894 struct __sp_compatible_with
898 template<
typename _Yp,
typename _Tp>
899 struct __sp_compatible_with<_Yp*, _Tp*>
900 : is_convertible<_Yp*, _Tp*>::type
903 template<
typename _Up,
size_t _Nm>
904 struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
908 template<
typename _Up,
size_t _Nm>
909 struct __sp_compatible_with<_Up(*)[_Nm],
const _Up(*)[]>
913 template<
typename _Up,
size_t _Nm>
914 struct __sp_compatible_with<_Up(*)[_Nm],
volatile _Up(*)[]>
918 template<
typename _Up,
size_t _Nm>
919 struct __sp_compatible_with<_Up(*)[_Nm],
const volatile _Up(*)[]>
924 template<
typename _Up,
size_t _Nm,
typename _Yp,
typename =
void>
925 struct __sp_is_constructible_arrN
929 template<
typename _Up,
size_t _Nm,
typename _Yp>
930 struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
931 : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
935 template<
typename _Up,
typename _Yp,
typename =
void>
936 struct __sp_is_constructible_arr
940 template<
typename _Up,
typename _Yp>
941 struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
942 : is_convertible<_Yp(*)[], _Up(*)[]>::type
946 template<
typename _Tp,
typename _Yp>
947 struct __sp_is_constructible;
950 template<
typename _Up,
size_t _Nm,
typename _Yp>
951 struct __sp_is_constructible<_Up[_Nm], _Yp>
952 : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
956 template<
typename _Up,
typename _Yp>
957 struct __sp_is_constructible<_Up[], _Yp>
958 : __sp_is_constructible_arr<_Up, _Yp>::type
962 template<
typename _Tp,
typename _Yp>
963 struct __sp_is_constructible
964 : is_convertible<_Yp*, _Tp*>::type
969 template<
typename _Tp, _Lock_policy _Lp,
970 bool = is_array<_Tp>::value,
bool = is_void<_Tp>::value>
971 class __shared_ptr_access
974 using element_type = _Tp;
979 __glibcxx_assert(_M_get() !=
nullptr);
984 operator->() const noexcept
986 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
992 _M_get() const noexcept
993 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
997 template<
typename _Tp, _Lock_policy _Lp>
998 class __shared_ptr_access<_Tp, _Lp, false, true>
1001 using element_type = _Tp;
1004 operator->() const noexcept
1006 auto __ptr =
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get();
1007 _GLIBCXX_DEBUG_PEDASSERT(__ptr !=
nullptr);
1013 template<
typename _Tp, _Lock_policy _Lp>
1014 class __shared_ptr_access<_Tp, _Lp, true, false>
1017 using element_type =
typename remove_extent<_Tp>::type;
1019#if __cplusplus <= 201402L
1020 [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
1024 __glibcxx_assert(_M_get() !=
nullptr);
1028 [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
1030 operator->() const noexcept
1032 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1038 operator[](ptrdiff_t __i)
const
1040 __glibcxx_assert(_M_get() !=
nullptr);
1041 __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
1042 return _M_get()[__i];
1047 _M_get() const noexcept
1048 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
1051 template<
typename _Tp, _Lock_policy _Lp>
1053 :
public __shared_ptr_access<_Tp, _Lp>
1056 using element_type =
typename remove_extent<_Tp>::type;
1060 template<
typename _Yp>
1062 =
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
1065 template<
typename _Yp,
typename _Res =
void>
1066 using _Compatible =
typename
1067 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1070 template<
typename _Yp>
1071 using _Assignable = _Compatible<_Yp, __shared_ptr&>;
1074 template<
typename _Yp,
typename _Del,
typename _Res = void,
1075 typename _Ptr =
typename unique_ptr<_Yp, _Del>::pointer>
1076 using _UniqCompatible = __enable_if_t<__and_<
1077 __sp_compatible_with<_Yp*, _Tp*>,
1078 is_convertible<_Ptr, element_type*>,
1079 is_move_constructible<_Del>
1083 template<
typename _Yp,
typename _Del>
1084 using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
1088#if __cplusplus > 201402L
1089 using weak_type = __weak_ptr<_Tp, _Lp>;
1092 constexpr __shared_ptr() noexcept
1093 : _M_ptr(0), _M_refcount()
1096 template<
typename _Yp,
typename = _SafeConv<_Yp>>
1098 __shared_ptr(_Yp* __p)
1099 : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
1101 static_assert( !is_void<_Yp>::value,
"incomplete type" );
1102 static_assert(
sizeof(_Yp) > 0,
"incomplete type" );
1103 _M_enable_shared_from_this_with(__p);
1106 template<
typename _Yp,
typename _Deleter,
typename = _SafeConv<_Yp>>
1107 __shared_ptr(_Yp* __p, _Deleter __d)
1108 : _M_ptr(__p), _M_refcount(__p,
std::
move(__d))
1110 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1111 "deleter expression d(p) is well-formed");
1112 _M_enable_shared_from_this_with(__p);
1115 template<
typename _Yp,
typename _Deleter,
typename _Alloc,
1116 typename = _SafeConv<_Yp>>
1117 __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
1120 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1121 "deleter expression d(p) is well-formed");
1122 _M_enable_shared_from_this_with(__p);
1125 template<
typename _Deleter>
1126 __shared_ptr(nullptr_t __p, _Deleter __d)
1127 : _M_ptr(0), _M_refcount(__p,
std::
move(__d))
1130 template<
typename _Deleter,
typename _Alloc>
1131 __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
1136 template<
typename _Yp>
1137 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
1138 element_type* __p) noexcept
1139 : _M_ptr(__p), _M_refcount(__r._M_refcount)
1143 template<
typename _Yp>
1144 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r,
1145 element_type* __p) noexcept
1146 : _M_ptr(__p), _M_refcount()
1148 _M_refcount._M_swap(__r._M_refcount);
1149 __r._M_ptr =
nullptr;
1152 __shared_ptr(
const __shared_ptr&)
noexcept =
default;
1153 __shared_ptr& operator=(
const __shared_ptr&)
noexcept =
default;
1154 ~__shared_ptr() =
default;
1156 template<
typename _Yp,
typename = _Compatible<_Yp>>
1157 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1158 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1161 __shared_ptr(__shared_ptr&& __r) noexcept
1162 : _M_ptr(__r._M_ptr), _M_refcount()
1164 _M_refcount._M_swap(__r._M_refcount);
1165 __r._M_ptr =
nullptr;
1168 template<
typename _Yp,
typename = _Compatible<_Yp>>
1169 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1170 : _M_ptr(__r._M_ptr), _M_refcount()
1172 _M_refcount._M_swap(__r._M_refcount);
1173 __r._M_ptr =
nullptr;
1176 template<
typename _Yp,
typename = _Compatible<_Yp>>
1177 explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
1178 : _M_refcount(__r._M_refcount)
1182 _M_ptr = __r._M_ptr;
1186 template<
typename _Yp,
typename _Del,
1187 typename = _UniqCompatible<_Yp, _Del>>
1188 __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
1189 : _M_ptr(__r.get()), _M_refcount()
1191 auto __raw = __to_address(__r.get());
1192 _M_refcount = __shared_count<_Lp>(
std::move(__r));
1193 _M_enable_shared_from_this_with(__raw);
1196#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED
1199 template<
typename _Tp1,
typename _Del,
1200 typename enable_if<__and_<
1201 __not_<is_array<_Tp>>, is_array<_Tp1>,
1202 is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
1203 >::value,
bool>::type =
true>
1204 __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
1205 : _M_ptr(__r.get()), _M_refcount()
1207 auto __raw = __to_address(__r.get());
1208 _M_refcount = __shared_count<_Lp>(
std::move(__r));
1209 _M_enable_shared_from_this_with(__raw);
1214#if _GLIBCXX_USE_DEPRECATED
1215#pragma GCC diagnostic push
1216#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1218 template<
typename _Yp,
typename = _Compatible<_Yp>>
1219 __shared_ptr(auto_ptr<_Yp>&& __r);
1220#pragma GCC diagnostic pop
1223 constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
1225 template<
typename _Yp>
1227 operator=(
const __shared_ptr<_Yp, _Lp>& __r)
noexcept
1229 _M_ptr = __r._M_ptr;
1230 _M_refcount = __r._M_refcount;
1234#if _GLIBCXX_USE_DEPRECATED
1235#pragma GCC diagnostic push
1236#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1237 template<
typename _Yp>
1239 operator=(auto_ptr<_Yp>&& __r)
1241 __shared_ptr(
std::move(__r)).swap(*
this);
1244#pragma GCC diagnostic pop
1248 operator=(__shared_ptr&& __r)
noexcept
1250 __shared_ptr(
std::move(__r)).swap(*
this);
1256 operator=(__shared_ptr<_Yp, _Lp>&& __r)
noexcept
1258 __shared_ptr(
std::move(__r)).swap(*
this);
1262 template<
typename _Yp,
typename _Del>
1263 _UniqAssignable<_Yp, _Del>
1264 operator=(unique_ptr<_Yp, _Del>&& __r)
1266 __shared_ptr(
std::move(__r)).swap(*
this);
1272 { __shared_ptr().swap(*
this); }
1274 template<
typename _Yp>
1279 __glibcxx_assert(__p ==
nullptr || __p != _M_ptr);
1280 __shared_ptr(__p).swap(*
this);
1283 template<
typename _Yp,
typename _Deleter>
1285 reset(_Yp* __p, _Deleter __d)
1286 { __shared_ptr(__p,
std::move(__d)).swap(*
this); }
1288 template<
typename _Yp,
typename _Deleter,
typename _Alloc>
1290 reset(_Yp* __p, _Deleter __d, _Alloc __a)
1295 get() const noexcept
1299 explicit operator bool() const noexcept
1300 {
return _M_ptr !=
nullptr; }
1304 unique() const noexcept
1305 {
return _M_refcount._M_unique(); }
1309 use_count() const noexcept
1310 {
return _M_refcount._M_get_use_count(); }
1314 swap(__shared_ptr<_Tp, _Lp>& __other)
noexcept
1317 _M_refcount._M_swap(__other._M_refcount);
1327 template<
typename _Tp1>
1329 owner_before(__shared_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1330 {
return _M_refcount._M_less(__rhs._M_refcount); }
1332 template<
typename _Tp1>
1334 owner_before(__weak_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1335 {
return _M_refcount._M_less(__rhs._M_refcount); }
1340 template<
typename _Alloc,
typename... _Args>
1341 __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
1342 : _M_ptr(), _M_refcount(_M_ptr, __tag,
std::
forward<_Args>(__args)...)
1343 { _M_enable_shared_from_this_with(_M_ptr); }
1345 template<
typename _Tp1, _Lock_policy _Lp1,
typename _Alloc,
1347 friend __shared_ptr<_Tp1, _Lp1>
1348 __allocate_shared(
const _Alloc& __a, _Args&&... __args);
1352 __shared_ptr(
const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t) noexcept
1353 : _M_refcount(__r._M_refcount, std::nothrow)
1355 _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr :
nullptr;
1358 friend class __weak_ptr<_Tp, _Lp>;
1362 template<
typename _Yp>
1363 using __esft_base_t =
decltype(__enable_shared_from_this_base(
1365 std::declval<_Yp*>()));
1368 template<
typename _Yp,
typename =
void>
1369 struct __has_esft_base
1372 template<
typename _Yp>
1373 struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
1374 : __not_<is_array<_Tp>> { };
1376 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1377 typename enable_if<__has_esft_base<_Yp2>::value>::type
1378 _M_enable_shared_from_this_with(_Yp* __p)
noexcept
1380 if (
auto __base = __enable_shared_from_this_base(_M_refcount, __p))
1381 __base->_M_weak_assign(
const_cast<_Yp2*
>(__p), _M_refcount);
1384 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1385 typename enable_if<!__has_esft_base<_Yp2>::value>::type
1386 _M_enable_shared_from_this_with(_Yp*)
noexcept
1391 {
return _M_refcount._M_get_deleter(__ti); }
1393 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1394 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1396 template<
typename _Del,
typename _Tp1, _Lock_policy _Lp1>
1397 friend _Del* get_deleter(
const __shared_ptr<_Tp1, _Lp1>&)
noexcept;
1399 template<
typename _Del,
typename _Tp1>
1400 friend _Del* get_deleter(
const shared_ptr<_Tp1>&)
noexcept;
1402 element_type* _M_ptr;
1403 __shared_count<_Lp> _M_refcount;
1408 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1410 operator==(
const __shared_ptr<_Tp1, _Lp>& __a,
1411 const __shared_ptr<_Tp2, _Lp>& __b)
noexcept
1412 {
return __a.get() == __b.get(); }
1414 template<
typename _Tp, _Lock_policy _Lp>
1416 operator==(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1419#ifdef __cpp_lib_three_way_comparison
1420 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1421 inline strong_ordering
1422 operator<=>(
const __shared_ptr<_Tp, _Lp>& __a,
1423 const __shared_ptr<_Up, _Lp>& __b)
noexcept
1424 {
return compare_three_way()(__a.get(), __b.get()); }
1426 template<
typename _Tp, _Lock_policy _Lp>
1427 inline strong_ordering
1428 operator<=>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1430 using pointer =
typename __shared_ptr<_Tp, _Lp>::element_type*;
1431 return compare_three_way()(__a.get(),
static_cast<pointer
>(
nullptr));
1434 template<
typename _Tp, _Lock_policy _Lp>
1436 operator==(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1439 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1441 operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
1442 const __shared_ptr<_Tp2, _Lp>& __b)
noexcept
1443 {
return __a.get() != __b.get(); }
1445 template<
typename _Tp, _Lock_policy _Lp>
1447 operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1448 {
return (
bool)__a; }
1450 template<
typename _Tp, _Lock_policy _Lp>
1452 operator!=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1453 {
return (
bool)__a; }
1455 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1457 operator<(
const __shared_ptr<_Tp, _Lp>& __a,
1458 const __shared_ptr<_Up, _Lp>& __b)
noexcept
1460 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1461 using _Up_elt =
typename __shared_ptr<_Up, _Lp>::element_type;
1462 using _Vp =
typename common_type<_Tp_elt*, _Up_elt*>::type;
1463 return less<_Vp>()(__a.get(), __b.get());
1466 template<
typename _Tp, _Lock_policy _Lp>
1468 operator<(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1470 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1471 return less<_Tp_elt*>()(__a.get(),
nullptr);
1474 template<
typename _Tp, _Lock_policy _Lp>
1476 operator<(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1478 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1479 return less<_Tp_elt*>()(
nullptr, __a.get());
1482 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1484 operator<=(
const __shared_ptr<_Tp1, _Lp>& __a,
1485 const __shared_ptr<_Tp2, _Lp>& __b)
noexcept
1486 {
return !(__b < __a); }
1488 template<
typename _Tp, _Lock_policy _Lp>
1490 operator<=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1491 {
return !(
nullptr < __a); }
1493 template<
typename _Tp, _Lock_policy _Lp>
1495 operator<=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1496 {
return !(__a <
nullptr); }
1498 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1500 operator>(
const __shared_ptr<_Tp1, _Lp>& __a,
1501 const __shared_ptr<_Tp2, _Lp>& __b)
noexcept
1502 {
return (__b < __a); }
1504 template<
typename _Tp, _Lock_policy _Lp>
1506 operator>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1507 {
return nullptr < __a; }
1509 template<
typename _Tp, _Lock_policy _Lp>
1511 operator>(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1512 {
return __a <
nullptr; }
1514 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1516 operator>=(
const __shared_ptr<_Tp1, _Lp>& __a,
1517 const __shared_ptr<_Tp2, _Lp>& __b)
noexcept
1518 {
return !(__a < __b); }
1520 template<
typename _Tp, _Lock_policy _Lp>
1522 operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t)
noexcept
1523 {
return !(__a <
nullptr); }
1525 template<
typename _Tp, _Lock_policy _Lp>
1527 operator>=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a)
noexcept
1528 {
return !(
nullptr < __a); }
1532 template<
typename _Tp, _Lock_policy _Lp>
1534 swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
noexcept
1544 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1545 inline __shared_ptr<_Tp, _Lp>
1548 using _Sp = __shared_ptr<_Tp, _Lp>;
1549 return _Sp(__r,
static_cast<typename _Sp::element_type*
>(__r.get()));
1557 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1558 inline __shared_ptr<_Tp, _Lp>
1561 using _Sp = __shared_ptr<_Tp, _Lp>;
1562 return _Sp(__r,
const_cast<typename _Sp::element_type*
>(__r.get()));
1570 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1571 inline __shared_ptr<_Tp, _Lp>
1574 using _Sp = __shared_ptr<_Tp, _Lp>;
1575 if (
auto* __p =
dynamic_cast<typename _Sp::element_type*
>(__r.get()))
1576 return _Sp(__r, __p);
1580#if __cplusplus > 201402L
1581 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1582 inline __shared_ptr<_Tp, _Lp>
1583 reinterpret_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r)
noexcept
1585 using _Sp = __shared_ptr<_Tp, _Lp>;
1586 return _Sp(__r,
reinterpret_cast<typename _Sp::element_type*
>(__r.get()));
1590 template<
typename _Tp, _Lock_policy _Lp>
1593 template<
typename _Yp,
typename _Res =
void>
1594 using _Compatible =
typename
1595 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1598 template<
typename _Yp>
1599 using _Assignable = _Compatible<_Yp, __weak_ptr&>;
1602 using element_type =
typename remove_extent<_Tp>::type;
1604 constexpr __weak_ptr() noexcept
1605 : _M_ptr(
nullptr), _M_refcount()
1608 __weak_ptr(
const __weak_ptr&)
noexcept =
default;
1610 ~__weak_ptr() =
default;
1626 template<
typename _Yp,
typename = _Compatible<_Yp>>
1627 __weak_ptr(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1628 : _M_refcount(__r._M_refcount)
1629 { _M_ptr = __r.lock().get(); }
1631 template<
typename _Yp,
typename = _Compatible<_Yp>>
1632 __weak_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1633 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1636 __weak_ptr(__weak_ptr&& __r) noexcept
1637 : _M_ptr(__r._M_ptr), _M_refcount(
std::move(__r._M_refcount))
1638 { __r._M_ptr =
nullptr; }
1640 template<
typename _Yp,
typename = _Compatible<_Yp>>
1641 __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1642 : _M_ptr(__r.lock().get()), _M_refcount(
std::move(__r._M_refcount))
1643 { __r._M_ptr =
nullptr; }
1646 operator=(
const __weak_ptr& __r)
noexcept =
default;
1648 template<
typename _Yp>
1650 operator=(
const __weak_ptr<_Yp, _Lp>& __r)
noexcept
1652 _M_ptr = __r.lock().get();
1653 _M_refcount = __r._M_refcount;
1657 template<
typename _Yp>
1659 operator=(
const __shared_ptr<_Yp, _Lp>& __r)
noexcept
1661 _M_ptr = __r._M_ptr;
1662 _M_refcount = __r._M_refcount;
1667 operator=(__weak_ptr&& __r)
noexcept
1673 template<
typename _Yp>
1675 operator=(__weak_ptr<_Yp, _Lp>&& __r)
noexcept
1677 _M_ptr = __r.lock().get();
1678 _M_refcount =
std::move(__r._M_refcount);
1679 __r._M_ptr =
nullptr;
1683 __shared_ptr<_Tp, _Lp>
1684 lock() const noexcept
1685 {
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
1688 use_count() const noexcept
1689 {
return _M_refcount._M_get_use_count(); }
1692 expired() const noexcept
1693 {
return _M_refcount._M_get_use_count() == 0; }
1695 template<
typename _Tp1>
1697 owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1698 {
return _M_refcount._M_less(__rhs._M_refcount); }
1700 template<
typename _Tp1>
1702 owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1703 {
return _M_refcount._M_less(__rhs._M_refcount); }
1707 { __weak_ptr().swap(*
this); }
1710 swap(__weak_ptr& __s)
noexcept
1713 _M_refcount._M_swap(__s._M_refcount);
1719 _M_assign(_Tp* __ptr,
const __shared_count<_Lp>& __refcount)
noexcept
1721 if (use_count() == 0)
1724 _M_refcount = __refcount;
1728 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1729 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1730 friend class __enable_shared_from_this<_Tp, _Lp>;
1731 friend class enable_shared_from_this<_Tp>;
1733 element_type* _M_ptr;
1734 __weak_count<_Lp> _M_refcount;
1738 template<
typename _Tp, _Lock_policy _Lp>
1740 swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b)
noexcept
1743 template<
typename _Tp,
typename _Tp1>
1744 struct _Sp_owner_less :
public binary_function<_Tp, _Tp, bool>
1747 operator()(
const _Tp& __lhs,
const _Tp& __rhs)
const noexcept
1748 {
return __lhs.owner_before(__rhs); }
1751 operator()(
const _Tp& __lhs,
const _Tp1& __rhs)
const noexcept
1752 {
return __lhs.owner_before(__rhs); }
1755 operator()(
const _Tp1& __lhs,
const _Tp& __rhs)
const noexcept
1756 {
return __lhs.owner_before(__rhs); }
1760 struct _Sp_owner_less<void, void>
1762 template<
typename _Tp,
typename _Up>
1764 operator()(
const _Tp& __lhs,
const _Up& __rhs)
const noexcept
1765 ->
decltype(__lhs.owner_before(__rhs))
1766 {
return __lhs.owner_before(__rhs); }
1768 using is_transparent = void;
1771 template<
typename _Tp, _Lock_policy _Lp>
1772 struct owner_less<__shared_ptr<_Tp, _Lp>>
1773 :
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
1776 template<
typename _Tp, _Lock_policy _Lp>
1777 struct owner_less<__weak_ptr<_Tp, _Lp>>
1778 :
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
1782 template<
typename _Tp, _Lock_policy _Lp>
1783 class __enable_shared_from_this
1786 constexpr __enable_shared_from_this() noexcept { }
1788 __enable_shared_from_this(
const __enable_shared_from_this&)
noexcept { }
1790 __enable_shared_from_this&
1791 operator=(
const __enable_shared_from_this&)
noexcept
1794 ~__enable_shared_from_this() { }
1797 __shared_ptr<_Tp, _Lp>
1799 {
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
1801 __shared_ptr<const _Tp, _Lp>
1802 shared_from_this()
const
1803 {
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
1805#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1806 __weak_ptr<_Tp, _Lp>
1807 weak_from_this() noexcept
1808 {
return this->_M_weak_this; }
1810 __weak_ptr<const _Tp, _Lp>
1811 weak_from_this() const noexcept
1812 {
return this->_M_weak_this; }
1816 template<
typename _Tp1>
1818 _M_weak_assign(_Tp1* __p,
const __shared_count<_Lp>& __n)
const noexcept
1819 { _M_weak_this._M_assign(__p, __n); }
1821 friend const __enable_shared_from_this*
1822 __enable_shared_from_this_base(
const __shared_count<_Lp>&,
1823 const __enable_shared_from_this* __p)
1826 template<
typename, _Lock_policy>
1827 friend class __shared_ptr;
1829 mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
1832 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1833 typename _Alloc,
typename... _Args>
1834 inline __shared_ptr<_Tp, _Lp>
1835 __allocate_shared(
const _Alloc& __a, _Args&&... __args)
1837 static_assert(!is_array<_Tp>::value,
"make_shared<T[]> not supported");
1839 return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a},
1840 std::forward<_Args>(__args)...);
1843 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy,
1845 inline __shared_ptr<_Tp, _Lp>
1846 __make_shared(_Args&&... __args)
1848 typedef typename std::remove_const<_Tp>::type _Tp_nc;
1850 std::forward<_Args>(__args)...);
1854 template<
typename _Tp, _Lock_policy _Lp>
1855 struct hash<__shared_ptr<_Tp, _Lp>>
1856 :
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
1859 operator()(
const __shared_ptr<_Tp, _Lp>& __s)
const noexcept
1866_GLIBCXX_END_NAMESPACE_VERSION
constexpr duration< __common_rep_t< _Rep2, _Rep1 >, _Period > operator*(const _Rep1 &__s, const duration< _Rep2, _Period > &__d)
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.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
ISO C++ entities toplevel namespace is std.
__shared_ptr< _Tp, _Lp > dynamic_pointer_cast(const __shared_ptr< _Tp1, _Lp > &__r) noexcept
dynamic_pointer_cast
__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
constexpr _Iterator __base(_Iterator __it)
Primary class template hash.
The standard allocator, as per C++03 [20.4.1].
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.