49 #ifndef _SHARED_PTR_BASE_H 50 #define _SHARED_PTR_BASE_H 1 56 #include <bits/refwrap.h> 60 namespace std _GLIBCXX_VISIBILITY(default)
62 _GLIBCXX_BEGIN_NAMESPACE_VERSION
64 #if _GLIBCXX_USE_DEPRECATED 65 template<
typename>
class auto_ptr;
75 virtual char const*
what()
const noexcept;
82 __throw_bad_weak_ptr()
85 using __gnu_cxx::_Lock_policy;
86 using __gnu_cxx::__default_lock_policy;
87 using __gnu_cxx::_S_single;
88 using __gnu_cxx::_S_mutex;
89 using __gnu_cxx::_S_atomic;
92 template<_Lock_policy _Lp>
97 enum { _S_need_barriers = 0 };
101 class _Mutex_base<_S_mutex>
102 :
public __gnu_cxx::__mutex
108 enum { _S_need_barriers = 1 };
111 template<_Lock_policy _Lp = __default_lock_policy>
112 class _Sp_counted_base
113 :
public _Mutex_base<_Lp>
116 _Sp_counted_base() noexcept
117 : _M_use_count(1), _M_weak_count(1) { }
120 ~_Sp_counted_base() noexcept
126 _M_dispose() noexcept = 0;
130 _M_destroy() noexcept
138 { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
144 _M_add_ref_lock_nothrow();
147 _M_release() noexcept
150 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
151 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
153 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count);
159 if (_Mutex_base<_Lp>::_S_need_barriers)
161 __atomic_thread_fence (__ATOMIC_ACQ_REL);
165 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
166 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
169 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
176 _M_weak_add_ref() noexcept
177 { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
180 _M_weak_release() noexcept
183 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
184 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
186 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
187 if (_Mutex_base<_Lp>::_S_need_barriers)
191 __atomic_thread_fence (__ATOMIC_ACQ_REL);
198 _M_get_use_count() const noexcept
202 return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
206 _Sp_counted_base(_Sp_counted_base
const&) =
delete;
207 _Sp_counted_base& operator=(_Sp_counted_base
const&) =
delete;
209 _Atomic_word _M_use_count;
210 _Atomic_word _M_weak_count;
215 _Sp_counted_base<_S_single>::
218 if (_M_use_count == 0)
219 __throw_bad_weak_ptr();
225 _Sp_counted_base<_S_mutex>::
229 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
232 __throw_bad_weak_ptr();
238 _Sp_counted_base<_S_atomic>::
242 _Atomic_word __count = _M_get_use_count();
246 __throw_bad_weak_ptr();
250 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
251 true, __ATOMIC_ACQ_REL,
257 _Sp_counted_base<_S_single>::
258 _M_add_ref_lock_nothrow()
260 if (_M_use_count == 0)
268 _Sp_counted_base<_S_mutex>::
269 _M_add_ref_lock_nothrow()
272 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
282 _Sp_counted_base<_S_atomic>::
283 _M_add_ref_lock_nothrow()
286 _Atomic_word __count = _M_get_use_count();
294 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
295 true, __ATOMIC_ACQ_REL,
302 _Sp_counted_base<_S_single>::_M_add_ref_copy()
307 _Sp_counted_base<_S_single>::_M_release() noexcept
309 if (--_M_use_count == 0)
312 if (--_M_weak_count == 0)
319 _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
324 _Sp_counted_base<_S_single>::_M_weak_release() noexcept
326 if (--_M_weak_count == 0)
332 _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
333 {
return _M_use_count; }
337 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
340 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
343 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
344 class __enable_shared_from_this;
346 template<
typename _Tp>
349 template<
typename _Tp>
352 template<
typename _Tp>
355 template<
typename _Tp>
356 class enable_shared_from_this;
358 template<_Lock_policy _Lp = __default_lock_policy>
361 template<_Lock_policy _Lp = __default_lock_policy>
362 class __shared_count;
366 template<
typename _Ptr, _Lock_policy _Lp>
367 class _Sp_counted_ptr final :
public _Sp_counted_base<_Lp>
371 _Sp_counted_ptr(_Ptr __p) noexcept
375 _M_dispose() noexcept
379 _M_destroy() noexcept
386 _Sp_counted_ptr(
const _Sp_counted_ptr&) =
delete;
387 _Sp_counted_ptr& operator=(
const _Sp_counted_ptr&) =
delete;
395 _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
399 _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
403 _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
405 template<
int _Nm,
typename _Tp,
406 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
407 struct _Sp_ebo_helper;
410 template<
int _Nm,
typename _Tp>
411 struct _Sp_ebo_helper<_Nm, _Tp, true> :
private _Tp
413 explicit _Sp_ebo_helper(
const _Tp& __tp) : _Tp(__tp) { }
414 explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { }
417 _S_get(_Sp_ebo_helper& __eboh) {
return static_cast<_Tp&
>(__eboh); }
421 template<
int _Nm,
typename _Tp>
422 struct _Sp_ebo_helper<_Nm, _Tp, false>
424 explicit _Sp_ebo_helper(
const _Tp& __tp) : _M_tp(__tp) { }
425 explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
428 _S_get(_Sp_ebo_helper& __eboh)
429 {
return __eboh._M_tp; }
436 template<
typename _Ptr,
typename _Deleter,
typename _Alloc, _Lock_policy _Lp>
437 class _Sp_counted_deleter final :
public _Sp_counted_base<_Lp>
439 class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc>
441 typedef _Sp_ebo_helper<0, _Deleter> _Del_base;
442 typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base;
445 _Impl(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
446 : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a)
449 _Deleter& _M_del() noexcept {
return _Del_base::_S_get(*
this); }
450 _Alloc& _M_alloc() noexcept {
return _Alloc_base::_S_get(*
this); }
456 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;
459 _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept
460 : _M_impl(__p, std::move(__d), _Alloc()) { }
463 _Sp_counted_deleter(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
464 : _M_impl(__p, std::move(__d), __a) { }
466 ~_Sp_counted_deleter() noexcept { }
469 _M_dispose() noexcept
470 { _M_impl._M_del()(_M_impl._M_ptr); }
473 _M_destroy() noexcept
475 __allocator_type __a(_M_impl._M_alloc());
476 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
477 this->~_Sp_counted_deleter();
486 return __ti ==
typeid(_Deleter)
500 struct _Sp_make_shared_tag { };
502 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
503 class _Sp_counted_ptr_inplace final :
public _Sp_counted_base<_Lp>
505 class _Impl : _Sp_ebo_helper<0, _Alloc>
507 typedef _Sp_ebo_helper<0, _Alloc> _A_base;
510 explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { }
512 _Alloc& _M_alloc() noexcept {
return _A_base::_S_get(*
this); }
514 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
518 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
520 template<
typename... _Args>
521 _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
527 std::forward<_Args>(__args)...);
530 ~_Sp_counted_ptr_inplace() noexcept { }
533 _M_dispose() noexcept
540 _M_destroy() noexcept
542 __allocator_type __a(_M_impl._M_alloc());
543 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
544 this->~_Sp_counted_ptr_inplace();
552 if (__ti ==
typeid(_Sp_make_shared_tag))
553 return const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
559 _Tp* _M_ptr() noexcept {
return _M_impl._M_storage._M_ptr(); }
565 struct __sp_array_delete
567 template<
typename _Yp>
568 void operator()(_Yp* __p)
const {
delete[] __p; }
571 template<_Lock_policy _Lp>
575 constexpr __shared_count() noexcept : _M_pi(0)
578 template<
typename _Ptr>
580 __shared_count(_Ptr __p) : _M_pi(0)
584 _M_pi =
new _Sp_counted_ptr<_Ptr, _Lp>(__p);
589 __throw_exception_again;
593 template<
typename _Ptr>
595 : __shared_count(__p)
598 template<
typename _Ptr>
600 : __shared_count(__p, __sp_array_delete{}, allocator<void>())
603 template<
typename _Ptr,
typename _Deleter>
604 __shared_count(_Ptr __p, _Deleter __d)
605 : __shared_count(__p,
std::move(__d), allocator<void>())
608 template<
typename _Ptr,
typename _Deleter,
typename _Alloc>
609 __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0)
611 typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type;
614 typename _Sp_cd_type::__allocator_type __a2(__a);
616 _Sp_cd_type* __mem = __guard.get();
617 ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a));
624 __throw_exception_again;
628 template<
typename _Tp,
typename _Alloc,
typename... _Args>
629 __shared_count(_Sp_make_shared_tag, _Tp*,
const _Alloc& __a,
633 typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
634 typename _Sp_cp_type::__allocator_type __a2(__a);
636 _Sp_cp_type* __mem = __guard.get();
637 ::new (__mem) _Sp_cp_type(std::move(__a),
638 std::forward<_Args>(__args)...);
643 #if _GLIBCXX_USE_DEPRECATED 645 template<
typename _Tp>
651 template<
typename _Tp,
typename _Del>
657 if (__r.get() ==
nullptr)
660 using _Ptr =
typename unique_ptr<_Tp, _Del>::pointer;
661 using _Del2 =
typename conditional<is_reference<_Del>::value,
662 reference_wrapper<typename remove_reference<_Del>::type>,
665 = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
666 using _Alloc = allocator<_Sp_cd_type>;
667 using _Alloc_traits = allocator_traits<_Alloc>;
669 _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1);
670 _Alloc_traits::construct(__a, __mem, __r.release(),
676 explicit __shared_count(
const __weak_count<_Lp>& __r);
679 explicit __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t);
681 ~__shared_count() noexcept
683 if (_M_pi !=
nullptr)
687 __shared_count(
const __shared_count& __r) noexcept
691 _M_pi->_M_add_ref_copy();
695 operator=(
const __shared_count& __r) noexcept
697 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
701 __tmp->_M_add_ref_copy();
710 _M_swap(__shared_count& __r) noexcept
712 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
718 _M_get_use_count() const noexcept
719 {
return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
722 _M_unique() const noexcept
723 {
return this->_M_get_use_count() == 1; }
727 {
return _M_pi ? _M_pi->_M_get_deleter(__ti) :
nullptr; }
730 _M_less(
const __shared_count& __rhs)
const noexcept
734 _M_less(
const __weak_count<_Lp>& __rhs)
const noexcept
739 operator==(
const __shared_count& __a,
const __shared_count& __b) noexcept
740 {
return __a._M_pi == __b._M_pi; }
743 friend class __weak_count<_Lp>;
745 _Sp_counted_base<_Lp>* _M_pi;
749 template<_Lock_policy _Lp>
753 constexpr __weak_count() noexcept : _M_pi(
nullptr)
756 __weak_count(
const __shared_count<_Lp>& __r) noexcept
759 if (_M_pi !=
nullptr)
760 _M_pi->_M_weak_add_ref();
763 __weak_count(
const __weak_count& __r) noexcept
766 if (_M_pi !=
nullptr)
767 _M_pi->_M_weak_add_ref();
770 __weak_count(__weak_count&& __r) noexcept
772 { __r._M_pi =
nullptr; }
774 ~__weak_count() noexcept
776 if (_M_pi !=
nullptr)
777 _M_pi->_M_weak_release();
781 operator=(
const __shared_count<_Lp>& __r) noexcept
783 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
784 if (__tmp !=
nullptr)
785 __tmp->_M_weak_add_ref();
786 if (_M_pi !=
nullptr)
787 _M_pi->_M_weak_release();
793 operator=(
const __weak_count& __r) noexcept
795 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
796 if (__tmp !=
nullptr)
797 __tmp->_M_weak_add_ref();
798 if (_M_pi !=
nullptr)
799 _M_pi->_M_weak_release();
805 operator=(__weak_count&& __r) noexcept
807 if (_M_pi !=
nullptr)
808 _M_pi->_M_weak_release();
815 _M_swap(__weak_count& __r) noexcept
817 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
823 _M_get_use_count() const noexcept
824 {
return _M_pi !=
nullptr ? _M_pi->_M_get_use_count() : 0; }
827 _M_less(
const __weak_count& __rhs)
const noexcept
831 _M_less(
const __shared_count<_Lp>& __rhs)
const noexcept
836 operator==(
const __weak_count& __a,
const __weak_count& __b) noexcept
837 {
return __a._M_pi == __b._M_pi; }
840 friend class __shared_count<_Lp>;
842 _Sp_counted_base<_Lp>* _M_pi;
846 template<_Lock_policy _Lp>
848 __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
851 if (_M_pi !=
nullptr)
852 _M_pi->_M_add_ref_lock();
854 __throw_bad_weak_ptr();
858 template<_Lock_policy _Lp>
860 __shared_count<_Lp>::
861 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t)
864 if (_M_pi !=
nullptr)
865 if (!_M_pi->_M_add_ref_lock_nothrow())
869 #define __cpp_lib_shared_ptr_arrays 201603 875 template<
typename _Yp_ptr,
typename _Tp_ptr>
876 struct __sp_compatible_with
880 template<
typename _Yp,
typename _Tp>
881 struct __sp_compatible_with<_Yp*, _Tp*>
882 : is_convertible<_Yp*, _Tp*>::type
885 template<
typename _Up,
size_t _Nm>
886 struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
890 template<
typename _Up,
size_t _Nm>
891 struct __sp_compatible_with<_Up(*)[_Nm],
const _Up(*)[]>
895 template<
typename _Up,
size_t _Nm>
896 struct __sp_compatible_with<_Up(*)[_Nm],
volatile _Up(*)[]>
900 template<
typename _Up,
size_t _Nm>
901 struct __sp_compatible_with<_Up(*)[_Nm],
const volatile _Up(*)[]>
906 template<
typename _Up,
size_t _Nm,
typename _Yp,
typename =
void>
907 struct __sp_is_constructible_arrN
911 template<
typename _Up,
size_t _Nm,
typename _Yp>
912 struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
913 : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
917 template<
typename _Up,
typename _Yp,
typename =
void>
918 struct __sp_is_constructible_arr
922 template<
typename _Up,
typename _Yp>
923 struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
924 : is_convertible<_Yp(*)[], _Up(*)[]>::type
928 template<
typename _Tp,
typename _Yp>
929 struct __sp_is_constructible;
932 template<
typename _Up,
size_t _Nm,
typename _Yp>
933 struct __sp_is_constructible<_Up[_Nm], _Yp>
934 : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
938 template<
typename _Up,
typename _Yp>
939 struct __sp_is_constructible<_Up[], _Yp>
940 : __sp_is_constructible_arr<_Up, _Yp>::type
944 template<
typename _Tp,
typename _Yp>
945 struct __sp_is_constructible
946 : is_convertible<_Yp*, _Tp*>::type
951 template<
typename _Tp, _Lock_policy _Lp,
952 bool = is_array<_Tp>::value,
bool = is_void<_Tp>::value>
953 class __shared_ptr_access
956 using element_type = _Tp;
961 __glibcxx_assert(_M_get() !=
nullptr);
966 operator->() const noexcept
968 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
974 _M_get() const noexcept
975 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
979 template<
typename _Tp, _Lock_policy _Lp>
980 class __shared_ptr_access<_Tp, _Lp, false, true>
983 using element_type = _Tp;
986 operator->() const noexcept
988 auto __ptr =
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get();
989 _GLIBCXX_DEBUG_PEDASSERT(__ptr !=
nullptr);
995 template<
typename _Tp, _Lock_policy _Lp>
996 class __shared_ptr_access<_Tp, _Lp, true, false>
999 using element_type =
typename remove_extent<_Tp>::type;
1001 #if __cplusplus <= 201402L 1002 [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
1006 __glibcxx_assert(_M_get() !=
nullptr);
1010 [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
1012 operator->() const noexcept
1014 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1020 operator[](ptrdiff_t __i)
const 1022 __glibcxx_assert(_M_get() !=
nullptr);
1023 __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
1024 return _M_get()[__i];
1029 _M_get() const noexcept
1030 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
1033 template<
typename _Tp, _Lock_policy _Lp>
1035 :
public __shared_ptr_access<_Tp, _Lp>
1038 using element_type =
typename remove_extent<_Tp>::type;
1042 template<
typename _Yp>
1044 =
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
1047 template<
typename _Yp,
typename _Res =
void>
1048 using _Compatible =
typename 1049 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1052 template<
typename _Yp>
1053 using _Assignable = _Compatible<_Yp, __shared_ptr&>;
1056 template<
typename _Yp,
typename _Del,
typename _Res = void,
1057 typename _Ptr =
typename unique_ptr<_Yp, _Del>::pointer>
1058 using _UniqCompatible =
typename enable_if<__and_<
1059 __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
1060 >::value, _Res>::type;
1063 template<
typename _Yp,
typename _Del>
1064 using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
1068 #if __cplusplus > 201402L 1069 using weak_type = __weak_ptr<_Tp, _Lp>;
1072 constexpr __shared_ptr() noexcept
1073 : _M_ptr(0), _M_refcount()
1076 template<
typename _Yp,
typename = _SafeConv<_Yp>>
1078 __shared_ptr(_Yp* __p)
1079 : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
1081 static_assert( !is_void<_Yp>::value,
"incomplete type" );
1082 static_assert(
sizeof(_Yp) > 0,
"incomplete type" );
1083 _M_enable_shared_from_this_with(__p);
1086 template<
typename _Yp,
typename _Deleter,
typename = _SafeConv<_Yp>>
1087 __shared_ptr(_Yp* __p, _Deleter __d)
1088 : _M_ptr(__p), _M_refcount(__p,
std::move(__d))
1090 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1091 "deleter expression d(p) is well-formed");
1092 _M_enable_shared_from_this_with(__p);
1095 template<
typename _Yp,
typename _Deleter,
typename _Alloc,
1096 typename = _SafeConv<_Yp>>
1097 __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
1098 : _M_ptr(__p), _M_refcount(__p,
std::move(__d),
std::move(__a))
1100 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1101 "deleter expression d(p) is well-formed");
1102 _M_enable_shared_from_this_with(__p);
1105 template<
typename _Deleter>
1106 __shared_ptr(nullptr_t __p, _Deleter __d)
1107 : _M_ptr(0), _M_refcount(__p,
std::move(__d))
1110 template<
typename _Deleter,
typename _Alloc>
1111 __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
1112 : _M_ptr(0), _M_refcount(__p,
std::move(__d),
std::move(__a))
1115 template<
typename _Yp>
1116 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
1117 element_type* __p) noexcept
1118 : _M_ptr(__p), _M_refcount(__r._M_refcount)
1121 __shared_ptr(
const __shared_ptr&) noexcept =
default;
1122 __shared_ptr& operator=(
const __shared_ptr&) noexcept =
default;
1123 ~__shared_ptr() =
default;
1125 template<
typename _Yp,
typename = _Compatible<_Yp>>
1126 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1127 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1130 __shared_ptr(__shared_ptr&& __r) noexcept
1131 : _M_ptr(__r._M_ptr), _M_refcount()
1133 _M_refcount._M_swap(__r._M_refcount);
1137 template<
typename _Yp,
typename = _Compatible<_Yp>>
1138 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1139 : _M_ptr(__r._M_ptr), _M_refcount()
1141 _M_refcount._M_swap(__r._M_refcount);
1145 template<
typename _Yp,
typename = _Compatible<_Yp>>
1146 explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
1147 : _M_refcount(__r._M_refcount)
1151 _M_ptr = __r._M_ptr;
1155 template<
typename _Yp,
typename _Del,
1156 typename = _UniqCompatible<_Yp, _Del>>
1157 __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
1158 : _M_ptr(__r.get()), _M_refcount()
1160 auto __raw = _S_raw_ptr(__r.get());
1161 _M_refcount = __shared_count<_Lp>(std::move(__r));
1162 _M_enable_shared_from_this_with(__raw);
1165 #if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED 1168 template<
typename _Tp1,
typename _Del,
1169 typename enable_if<__and_<
1170 __not_<is_array<_Tp>>, is_array<_Tp1>,
1171 is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
1172 >::value,
bool>::type =
true>
1173 __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
1174 : _M_ptr(__r.get()), _M_refcount()
1176 auto __raw = _S_raw_ptr(__r.get());
1177 _M_refcount = __shared_count<_Lp>(std::move(__r));
1178 _M_enable_shared_from_this_with(__raw);
1183 #if _GLIBCXX_USE_DEPRECATED 1185 template<
typename _Yp,
typename = _Compatible<_Yp>>
1186 __shared_ptr(auto_ptr<_Yp>&& __r);
1189 constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
1191 template<
typename _Yp>
1193 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1195 _M_ptr = __r._M_ptr;
1196 _M_refcount = __r._M_refcount;
1200 #if _GLIBCXX_USE_DEPRECATED 1201 template<
typename _Yp>
1203 operator=(auto_ptr<_Yp>&& __r)
1205 __shared_ptr(std::move(__r)).swap(*
this);
1211 operator=(__shared_ptr&& __r) noexcept
1213 __shared_ptr(std::move(__r)).swap(*
this);
1219 operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1221 __shared_ptr(std::move(__r)).swap(*
this);
1225 template<
typename _Yp,
typename _Del>
1226 _UniqAssignable<_Yp, _Del>
1227 operator=(unique_ptr<_Yp, _Del>&& __r)
1229 __shared_ptr(std::move(__r)).swap(*
this);
1235 { __shared_ptr().swap(*
this); }
1237 template<
typename _Yp>
1242 __glibcxx_assert(__p == 0 || __p != _M_ptr);
1243 __shared_ptr(__p).swap(*
this);
1246 template<
typename _Yp,
typename _Deleter>
1248 reset(_Yp* __p, _Deleter __d)
1249 { __shared_ptr(__p, std::move(__d)).swap(*
this); }
1251 template<
typename _Yp,
typename _Deleter,
typename _Alloc>
1253 reset(_Yp* __p, _Deleter __d, _Alloc __a)
1254 { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*
this); }
1257 get()
const noexcept
1260 explicit operator bool() const
1261 {
return _M_ptr == 0 ? false :
true; }
1264 unique() const noexcept
1265 {
return _M_refcount._M_unique(); }
1268 use_count() const noexcept
1269 {
return _M_refcount._M_get_use_count(); }
1272 swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
1274 std::swap(_M_ptr, __other._M_ptr);
1275 _M_refcount._M_swap(__other._M_refcount);
1278 template<
typename _Tp1>
1280 owner_before(__shared_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1281 {
return _M_refcount._M_less(__rhs._M_refcount); }
1283 template<
typename _Tp1>
1285 owner_before(__weak_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1286 {
return _M_refcount._M_less(__rhs._M_refcount); }
1291 template<
typename _Alloc,
typename... _Args>
1292 __shared_ptr(_Sp_make_shared_tag __tag,
const _Alloc& __a,
1294 : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
1299 void* __p = _M_refcount._M_get_deleter(
typeid(__tag));
1300 _M_ptr =
static_cast<_Tp*
>(__p);
1301 _M_enable_shared_from_this_with(_M_ptr);
1304 template<
typename _Alloc>
1307 void operator()(
typename _Alloc::value_type* __ptr)
1309 __allocated_ptr<_Alloc> __guard{ _M_alloc, __ptr };
1315 template<
typename _Alloc,
typename... _Args>
1316 __shared_ptr(_Sp_make_shared_tag __tag,
const _Alloc& __a,
1318 : _M_ptr(), _M_refcount()
1320 typedef typename allocator_traits<_Alloc>::template
1321 rebind_traits<typename std::remove_cv<_Tp>::type> __traits;
1322 _Deleter<typename __traits::allocator_type> __del = { __a };
1324 auto __ptr = __guard.get();
1327 __traits::construct(__del._M_alloc, __ptr,
1328 std::forward<_Args>(__args)...);
1330 __shared_count<_Lp> __count(__ptr, __del, __del._M_alloc);
1331 _M_refcount._M_swap(__count);
1333 _M_enable_shared_from_this_with(_M_ptr);
1337 template<
typename _Tp1, _Lock_policy _Lp1,
typename _Alloc,
1339 friend __shared_ptr<_Tp1, _Lp1>
1340 __allocate_shared(
const _Alloc& __a, _Args&&... __args);
1344 __shared_ptr(
const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t)
1345 : _M_refcount(__r._M_refcount,
std::nothrow)
1347 _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr :
nullptr;
1350 friend class __weak_ptr<_Tp, _Lp>;
1354 template<
typename _Yp>
1355 using __esft_base_t = decltype(__enable_shared_from_this_base(
1356 std::declval<
const __shared_count<_Lp>&>(),
1357 std::declval<_Yp*>()));
1360 template<
typename _Yp,
typename =
void>
1361 struct __has_esft_base
1364 template<
typename _Yp>
1365 struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
1366 : __not_<is_array<_Tp>> { };
1368 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1369 typename enable_if<__has_esft_base<_Yp2>::value>::type
1370 _M_enable_shared_from_this_with(_Yp* __p) noexcept
1372 if (
auto __base = __enable_shared_from_this_base(_M_refcount, __p))
1373 __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount);
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*) noexcept
1383 {
return _M_refcount._M_get_deleter(__ti); }
1385 template<
typename _Tp1>
1387 _S_raw_ptr(_Tp1* __ptr)
1390 template<
typename _Tp1>
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 element_type* _M_ptr;
1402 __shared_count<_Lp> _M_refcount;
1407 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1409 operator==(
const __shared_ptr<_Tp1, _Lp>& __a,
1410 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1411 {
return __a.get() == __b.get(); }
1413 template<
typename _Tp, _Lock_policy _Lp>
1415 operator==(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1418 template<
typename _Tp, _Lock_policy _Lp>
1420 operator==(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1423 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1425 operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
1426 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1427 {
return __a.get() != __b.get(); }
1429 template<
typename _Tp, _Lock_policy _Lp>
1431 operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1432 {
return (
bool)__a; }
1434 template<
typename _Tp, _Lock_policy _Lp>
1436 operator!=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1437 {
return (
bool)__a; }
1439 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1441 operator<(const __shared_ptr<_Tp, _Lp>& __a,
1442 const __shared_ptr<_Up, _Lp>& __b) noexcept
1444 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1445 using _Up_elt =
typename __shared_ptr<_Up, _Lp>::element_type;
1446 using _Vp =
typename common_type<_Tp_elt*, _Up_elt*>::type;
1447 return less<_Vp>()(__a.get(), __b.get());
1450 template<
typename _Tp, _Lock_policy _Lp>
1452 operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1454 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1455 return less<_Tp_elt*>()(__a.get(),
nullptr);
1458 template<
typename _Tp, _Lock_policy _Lp>
1460 operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1462 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1463 return less<_Tp_elt*>()(
nullptr, __a.get());
1466 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1468 operator<=(const __shared_ptr<_Tp1, _Lp>& __a,
1469 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1470 {
return !(__b < __a); }
1472 template<
typename _Tp, _Lock_policy _Lp>
1474 operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1475 {
return !(
nullptr < __a); }
1477 template<
typename _Tp, _Lock_policy _Lp>
1479 operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1480 {
return !(__a <
nullptr); }
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 !(__a < __b); }
1504 template<
typename _Tp, _Lock_policy _Lp>
1506 operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1507 {
return !(__a <
nullptr); }
1509 template<
typename _Tp, _Lock_policy _Lp>
1511 operator>=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1512 {
return !(
nullptr < __a); }
1514 template<
typename _Sp>
1515 struct _Sp_less :
public binary_function<_Sp, _Sp, bool>
1518 operator()(
const _Sp& __lhs,
const _Sp& __rhs)
const noexcept
1520 typedef typename _Sp::element_type element_type;
1525 template<
typename _Tp, _Lock_policy _Lp>
1526 struct less<__shared_ptr<_Tp, _Lp>>
1527 :
public _Sp_less<__shared_ptr<_Tp, _Lp>>
1531 template<
typename _Tp, _Lock_policy _Lp>
1533 swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
1543 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1544 inline __shared_ptr<_Tp, _Lp>
1545 static_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1547 using _Sp = __shared_ptr<_Tp, _Lp>;
1548 return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get()));
1556 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1557 inline __shared_ptr<_Tp, _Lp>
1558 const_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1560 using _Sp = __shared_ptr<_Tp, _Lp>;
1561 return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get()));
1569 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1570 inline __shared_ptr<_Tp, _Lp>
1571 dynamic_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1573 using _Sp = __shared_ptr<_Tp, _Lp>;
1574 if (
auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get()))
1575 return _Sp(__r, __p);
1579 #if __cplusplus > 201402L 1580 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1581 inline __shared_ptr<_Tp, _Lp>
1582 reinterpret_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1584 using _Sp = __shared_ptr<_Tp, _Lp>;
1585 return _Sp(__r, reinterpret_cast<typename _Sp::element_type*>(__r.get()));
1589 template<
typename _Tp, _Lock_policy _Lp>
1592 template<
typename _Yp,
typename _Res =
void>
1593 using _Compatible =
typename 1594 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1597 template<
typename _Yp>
1598 using _Assignable = _Compatible<_Yp, __weak_ptr&>;
1601 using element_type =
typename remove_extent<_Tp>::type;
1603 constexpr __weak_ptr() noexcept
1604 : _M_ptr(
nullptr), _M_refcount()
1607 __weak_ptr(
const __weak_ptr&) noexcept =
default;
1609 ~__weak_ptr() =
default;
1625 template<
typename _Yp,
typename = _Compatible<_Yp>>
1626 __weak_ptr(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1627 : _M_refcount(__r._M_refcount)
1628 { _M_ptr = __r.lock().get(); }
1630 template<
typename _Yp,
typename = _Compatible<_Yp>>
1631 __weak_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1632 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1635 __weak_ptr(__weak_ptr&& __r) noexcept
1636 : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount))
1637 { __r._M_ptr =
nullptr; }
1639 template<
typename _Yp,
typename = _Compatible<_Yp>>
1640 __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1641 : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount))
1642 { __r._M_ptr =
nullptr; }
1645 operator=(
const __weak_ptr& __r) noexcept =
default;
1647 template<
typename _Yp>
1649 operator=(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1651 _M_ptr = __r.lock().get();
1652 _M_refcount = __r._M_refcount;
1656 template<
typename _Yp>
1658 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1660 _M_ptr = __r._M_ptr;
1661 _M_refcount = __r._M_refcount;
1666 operator=(__weak_ptr&& __r) noexcept
1668 _M_ptr = __r._M_ptr;
1669 _M_refcount = std::move(__r._M_refcount);
1670 __r._M_ptr =
nullptr;
1674 template<
typename _Yp>
1676 operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1678 _M_ptr = __r.lock().get();
1679 _M_refcount = std::move(__r._M_refcount);
1680 __r._M_ptr =
nullptr;
1684 __shared_ptr<_Tp, _Lp>
1685 lock() const noexcept
1686 {
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
1689 use_count() const noexcept
1690 {
return _M_refcount._M_get_use_count(); }
1693 expired() const noexcept
1694 {
return _M_refcount._M_get_use_count() == 0; }
1696 template<
typename _Tp1>
1698 owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1699 {
return _M_refcount._M_less(__rhs._M_refcount); }
1701 template<
typename _Tp1>
1703 owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1704 {
return _M_refcount._M_less(__rhs._M_refcount); }
1708 { __weak_ptr().swap(*
this); }
1711 swap(__weak_ptr& __s) noexcept
1713 std::swap(_M_ptr, __s._M_ptr);
1714 _M_refcount._M_swap(__s._M_refcount);
1720 _M_assign(_Tp* __ptr,
const __shared_count<_Lp>& __refcount) noexcept
1722 if (use_count() == 0)
1725 _M_refcount = __refcount;
1729 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1730 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1731 friend class __enable_shared_from_this<_Tp, _Lp>;
1732 friend class enable_shared_from_this<_Tp>;
1734 element_type* _M_ptr;
1735 __weak_count<_Lp> _M_refcount;
1739 template<
typename _Tp, _Lock_policy _Lp>
1741 swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
1744 template<
typename _Tp,
typename _Tp1>
1745 struct _Sp_owner_less :
public binary_function<_Tp, _Tp, bool>
1748 operator()(
const _Tp& __lhs,
const _Tp& __rhs)
const noexcept
1749 {
return __lhs.owner_before(__rhs); }
1752 operator()(
const _Tp& __lhs,
const _Tp1& __rhs)
const noexcept
1753 {
return __lhs.owner_before(__rhs); }
1756 operator()(
const _Tp1& __lhs,
const _Tp& __rhs)
const noexcept
1757 {
return __lhs.owner_before(__rhs); }
1761 struct _Sp_owner_less<void, void>
1763 template<
typename _Tp,
typename _Up>
1765 operator()(
const _Tp& __lhs,
const _Up& __rhs)
const noexcept
1766 -> decltype(__lhs.owner_before(__rhs))
1767 {
return __lhs.owner_before(__rhs); }
1769 using is_transparent = void;
1772 template<
typename _Tp, _Lock_policy _Lp>
1773 struct owner_less<__shared_ptr<_Tp, _Lp>>
1774 :
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
1777 template<
typename _Tp, _Lock_policy _Lp>
1778 struct owner_less<__weak_ptr<_Tp, _Lp>>
1779 :
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
1783 template<
typename _Tp, _Lock_policy _Lp>
1784 class __enable_shared_from_this
1787 constexpr __enable_shared_from_this() noexcept { }
1789 __enable_shared_from_this(
const __enable_shared_from_this&) noexcept { }
1791 __enable_shared_from_this&
1792 operator=(
const __enable_shared_from_this&) noexcept
1795 ~__enable_shared_from_this() { }
1798 __shared_ptr<_Tp, _Lp>
1800 {
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
1802 __shared_ptr<const _Tp, _Lp>
1803 shared_from_this()
const 1804 {
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
1806 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1807 __weak_ptr<_Tp, _Lp>
1808 weak_from_this() noexcept
1809 {
return this->_M_weak_this; }
1811 __weak_ptr<const _Tp, _Lp>
1812 weak_from_this() const noexcept
1813 {
return this->_M_weak_this; }
1817 template<
typename _Tp1>
1819 _M_weak_assign(_Tp1* __p,
const __shared_count<_Lp>& __n)
const noexcept
1820 { _M_weak_this._M_assign(__p, __n); }
1822 friend const __enable_shared_from_this*
1823 __enable_shared_from_this_base(
const __shared_count<_Lp>&,
1824 const __enable_shared_from_this* __p)
1827 template<
typename, _Lock_policy>
1828 friend class __shared_ptr;
1830 mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
1833 template<
typename _Tp, _Lock_policy _Lp,
typename _Alloc,
typename... _Args>
1834 inline __shared_ptr<_Tp, _Lp>
1835 __allocate_shared(
const _Alloc& __a, _Args&&... __args)
1837 return __shared_ptr<_Tp, _Lp>(_Sp_make_shared_tag(), __a,
1838 std::forward<_Args>(__args)...);
1841 template<
typename _Tp, _Lock_policy _Lp,
typename... _Args>
1842 inline __shared_ptr<_Tp, _Lp>
1843 __make_shared(_Args&&... __args)
1845 typedef typename std::remove_const<_Tp>::type _Tp_nc;
1847 std::forward<_Args>(__args)...);
1851 template<
typename _Tp, _Lock_policy _Lp>
1852 struct hash<__shared_ptr<_Tp, _Lp>>
1853 :
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
1856 operator()(
const __shared_ptr<_Tp, _Lp>& __s)
const noexcept
1863 _GLIBCXX_END_NAMESPACE_VERSION
1866 #endif // _SHARED_PTR_BASE_H
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
The standard allocator, as per [20.4].
static auto construct(_Alloc &__a, _Tp *__p, _Args &&... __args) -> decltype(_S_construct(__a, __p, std::forward< _Args >(__args)...))
Construct an object of type _Tp.
A simple smart pointer providing strict ownership semantics.
static void destroy(_Alloc &__a, _Tp *__p)
Destroy an object of type _Tp.
Base class for all library exceptions.
One of the comparison functors.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
20.7.1.2 unique_ptr for single objects.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
virtual char const * what() const noexcept
__allocated_ptr< _Alloc > __allocate_guarded(_Alloc &__a)
Allocate space for a single object using __a.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
ISO C++ entities toplevel namespace is std.
Exception possibly thrown by shared_ptr.
_Del * get_deleter(const __shared_ptr< _Tp, _Lp > &__p) noexcept
20.7.2.2.10 shared_ptr get_deleter
Primary class template hash.
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.