49 #ifndef _SHARED_PTR_BASE_H 50 #define _SHARED_PTR_BASE_H 1 60 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_VERSION
68 #if _GLIBCXX_USE_DEPRECATED 69 #pragma GCC diagnostic push 70 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 71 template<
typename>
class auto_ptr;
72 #pragma GCC diagnostic pop 82 virtual char const*
what()
const noexcept;
89 __throw_bad_weak_ptr()
92 using __gnu_cxx::_Lock_policy;
93 using __gnu_cxx::__default_lock_policy;
94 using __gnu_cxx::_S_single;
95 using __gnu_cxx::_S_mutex;
96 using __gnu_cxx::_S_atomic;
99 template<_Lock_policy _Lp>
104 enum { _S_need_barriers = 0 };
108 class _Mutex_base<_S_mutex>
109 :
public __gnu_cxx::__mutex
115 enum { _S_need_barriers = 1 };
118 template<_Lock_policy _Lp = __default_lock_policy>
119 class _Sp_counted_base
120 :
public _Mutex_base<_Lp>
123 _Sp_counted_base() noexcept
124 : _M_use_count(1), _M_weak_count(1) { }
127 ~_Sp_counted_base() noexcept
133 _M_dispose() noexcept = 0;
137 _M_destroy() noexcept
145 { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
151 _M_add_ref_lock_nothrow();
154 _M_release() noexcept
157 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
158 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
160 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count);
166 if (_Mutex_base<_Lp>::_S_need_barriers)
168 __atomic_thread_fence (__ATOMIC_ACQ_REL);
172 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
173 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
176 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
183 _M_weak_add_ref() noexcept
184 { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
187 _M_weak_release() noexcept
190 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
191 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
193 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
194 if (_Mutex_base<_Lp>::_S_need_barriers)
198 __atomic_thread_fence (__ATOMIC_ACQ_REL);
205 _M_get_use_count() const noexcept
209 return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
213 _Sp_counted_base(_Sp_counted_base
const&) =
delete;
214 _Sp_counted_base& operator=(_Sp_counted_base
const&) =
delete;
216 _Atomic_word _M_use_count;
217 _Atomic_word _M_weak_count;
222 _Sp_counted_base<_S_single>::
225 if (_M_use_count == 0)
226 __throw_bad_weak_ptr();
232 _Sp_counted_base<_S_mutex>::
236 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
239 __throw_bad_weak_ptr();
245 _Sp_counted_base<_S_atomic>::
249 _Atomic_word __count = _M_get_use_count();
253 __throw_bad_weak_ptr();
257 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
258 true, __ATOMIC_ACQ_REL,
264 _Sp_counted_base<_S_single>::
265 _M_add_ref_lock_nothrow()
267 if (_M_use_count == 0)
275 _Sp_counted_base<_S_mutex>::
276 _M_add_ref_lock_nothrow()
279 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
289 _Sp_counted_base<_S_atomic>::
290 _M_add_ref_lock_nothrow()
293 _Atomic_word __count = _M_get_use_count();
301 while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
302 true, __ATOMIC_ACQ_REL,
309 _Sp_counted_base<_S_single>::_M_add_ref_copy()
314 _Sp_counted_base<_S_single>::_M_release() noexcept
316 if (--_M_use_count == 0)
319 if (--_M_weak_count == 0)
326 _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
331 _Sp_counted_base<_S_single>::_M_weak_release() noexcept
333 if (--_M_weak_count == 0)
339 _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
340 {
return _M_use_count; }
344 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
347 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
350 template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
351 class __enable_shared_from_this;
353 template<
typename _Tp>
356 template<
typename _Tp>
359 template<
typename _Tp>
362 template<
typename _Tp>
363 class enable_shared_from_this;
365 template<_Lock_policy _Lp = __default_lock_policy>
368 template<_Lock_policy _Lp = __default_lock_policy>
369 class __shared_count;
373 template<
typename _Ptr, _Lock_policy _Lp>
374 class _Sp_counted_ptr final :
public _Sp_counted_base<_Lp>
378 _Sp_counted_ptr(_Ptr __p) noexcept
382 _M_dispose() noexcept
386 _M_destroy() noexcept
393 _Sp_counted_ptr(
const _Sp_counted_ptr&) =
delete;
394 _Sp_counted_ptr& operator=(
const _Sp_counted_ptr&) =
delete;
402 _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
406 _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
410 _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
412 template<
int _Nm,
typename _Tp,
413 bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
414 struct _Sp_ebo_helper;
417 template<
int _Nm,
typename _Tp>
418 struct _Sp_ebo_helper<_Nm, _Tp, true> :
private _Tp
420 explicit _Sp_ebo_helper(
const _Tp& __tp) : _Tp(__tp) { }
421 explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { }
424 _S_get(_Sp_ebo_helper& __eboh) {
return static_cast<_Tp&
>(__eboh); }
428 template<
int _Nm,
typename _Tp>
429 struct _Sp_ebo_helper<_Nm, _Tp, false>
431 explicit _Sp_ebo_helper(
const _Tp& __tp) : _M_tp(__tp) { }
432 explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
435 _S_get(_Sp_ebo_helper& __eboh)
436 {
return __eboh._M_tp; }
443 template<
typename _Ptr,
typename _Deleter,
typename _Alloc, _Lock_policy _Lp>
444 class _Sp_counted_deleter final :
public _Sp_counted_base<_Lp>
446 class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc>
448 typedef _Sp_ebo_helper<0, _Deleter> _Del_base;
449 typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base;
452 _Impl(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
453 : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a)
456 _Deleter& _M_del() noexcept {
return _Del_base::_S_get(*
this); }
457 _Alloc& _M_alloc() noexcept {
return _Alloc_base::_S_get(*
this); }
463 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;
466 _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept
467 : _M_impl(__p, std::move(__d), _Alloc()) { }
470 _Sp_counted_deleter(_Ptr __p, _Deleter __d,
const _Alloc& __a) noexcept
471 : _M_impl(__p, std::move(__d), __a) { }
473 ~_Sp_counted_deleter() noexcept { }
476 _M_dispose() noexcept
477 { _M_impl._M_del()(_M_impl._M_ptr); }
480 _M_destroy() noexcept
482 __allocator_type __a(_M_impl._M_alloc());
483 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
484 this->~_Sp_counted_deleter();
493 return __ti ==
typeid(_Deleter)
507 struct _Sp_make_shared_tag
511 template<
typename _Tp, _Lock_policy _Lp>
512 friend class __shared_ptr;
513 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
514 friend class _Sp_counted_ptr_inplace;
516 static const type_info&
519 static constexpr _Sp_make_shared_tag __tag;
520 return reinterpret_cast<const type_info&
>(__tag);
525 template<
typename _Tp,
typename _Alloc, _Lock_policy _Lp>
526 class _Sp_counted_ptr_inplace final :
public _Sp_counted_base<_Lp>
528 class _Impl : _Sp_ebo_helper<0, _Alloc>
530 typedef _Sp_ebo_helper<0, _Alloc> _A_base;
533 explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { }
535 _Alloc& _M_alloc() noexcept {
return _A_base::_S_get(*
this); }
537 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
541 using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
543 template<
typename... _Args>
544 _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
550 std::forward<_Args>(__args)...);
553 ~_Sp_counted_ptr_inplace() noexcept { }
556 _M_dispose() noexcept
563 _M_destroy() noexcept
565 __allocator_type __a(_M_impl._M_alloc());
566 __allocated_ptr<__allocator_type> __guard_ptr{ __a,
this };
567 this->~_Sp_counted_ptr_inplace();
575 if (__ti ==
typeid(_Sp_make_shared_tag))
577 if (&__ti == &_Sp_make_shared_tag::_S_ti())
579 return const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
584 _Tp* _M_ptr() noexcept {
return _M_impl._M_storage._M_ptr(); }
590 struct __sp_array_delete
592 template<
typename _Yp>
593 void operator()(_Yp* __p)
const {
delete[] __p; }
596 template<_Lock_policy _Lp>
600 constexpr __shared_count() noexcept : _M_pi(0)
603 template<
typename _Ptr>
605 __shared_count(_Ptr __p) : _M_pi(0)
609 _M_pi =
new _Sp_counted_ptr<_Ptr, _Lp>(__p);
614 __throw_exception_again;
618 template<
typename _Ptr>
620 : __shared_count(__p)
623 template<
typename _Ptr>
625 : __shared_count(__p, __sp_array_delete{}, allocator<void>())
628 template<
typename _Ptr,
typename _Deleter>
629 __shared_count(_Ptr __p, _Deleter __d)
630 : __shared_count(__p,
std::move(__d), allocator<void>())
633 template<
typename _Ptr,
typename _Deleter,
typename _Alloc>
634 __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0)
636 typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type;
639 typename _Sp_cd_type::__allocator_type __a2(__a);
641 _Sp_cd_type* __mem = __guard.get();
642 ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a));
649 __throw_exception_again;
653 template<
typename _Tp,
typename _Alloc,
typename... _Args>
654 __shared_count(_Sp_make_shared_tag, _Tp*,
const _Alloc& __a,
658 typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
659 typename _Sp_cp_type::__allocator_type __a2(__a);
661 _Sp_cp_type* __mem = __guard.get();
662 ::new (__mem) _Sp_cp_type(std::move(__a),
663 std::forward<_Args>(__args)...);
668 #if _GLIBCXX_USE_DEPRECATED 669 #pragma GCC diagnostic push 670 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 672 template<
typename _Tp>
675 #pragma GCC diagnostic pop 679 template<
typename _Tp,
typename _Del>
685 if (__r.get() ==
nullptr)
688 using _Ptr =
typename unique_ptr<_Tp, _Del>::pointer;
689 using _Del2 =
typename conditional<is_reference<_Del>::value,
690 reference_wrapper<typename remove_reference<_Del>::type>,
693 = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
694 using _Alloc = allocator<_Sp_cd_type>;
695 using _Alloc_traits = allocator_traits<_Alloc>;
697 _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1);
698 _Alloc_traits::construct(__a, __mem, __r.release(),
704 explicit __shared_count(
const __weak_count<_Lp>& __r);
707 explicit __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t);
709 ~__shared_count() noexcept
711 if (_M_pi !=
nullptr)
715 __shared_count(
const __shared_count& __r) noexcept
719 _M_pi->_M_add_ref_copy();
723 operator=(
const __shared_count& __r) noexcept
725 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
729 __tmp->_M_add_ref_copy();
738 _M_swap(__shared_count& __r) noexcept
740 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
746 _M_get_use_count() const noexcept
747 {
return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
750 _M_unique() const noexcept
751 {
return this->_M_get_use_count() == 1; }
755 {
return _M_pi ? _M_pi->_M_get_deleter(__ti) :
nullptr; }
758 _M_less(
const __shared_count& __rhs)
const noexcept
762 _M_less(
const __weak_count<_Lp>& __rhs)
const noexcept
767 operator==(
const __shared_count& __a,
const __shared_count& __b) noexcept
768 {
return __a._M_pi == __b._M_pi; }
771 friend class __weak_count<_Lp>;
773 _Sp_counted_base<_Lp>* _M_pi;
777 template<_Lock_policy _Lp>
781 constexpr __weak_count() noexcept : _M_pi(
nullptr)
784 __weak_count(
const __shared_count<_Lp>& __r) noexcept
787 if (_M_pi !=
nullptr)
788 _M_pi->_M_weak_add_ref();
791 __weak_count(
const __weak_count& __r) noexcept
794 if (_M_pi !=
nullptr)
795 _M_pi->_M_weak_add_ref();
798 __weak_count(__weak_count&& __r) noexcept
800 { __r._M_pi =
nullptr; }
802 ~__weak_count() noexcept
804 if (_M_pi !=
nullptr)
805 _M_pi->_M_weak_release();
809 operator=(
const __shared_count<_Lp>& __r) noexcept
811 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
812 if (__tmp !=
nullptr)
813 __tmp->_M_weak_add_ref();
814 if (_M_pi !=
nullptr)
815 _M_pi->_M_weak_release();
821 operator=(
const __weak_count& __r) noexcept
823 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
824 if (__tmp !=
nullptr)
825 __tmp->_M_weak_add_ref();
826 if (_M_pi !=
nullptr)
827 _M_pi->_M_weak_release();
833 operator=(__weak_count&& __r) noexcept
835 if (_M_pi !=
nullptr)
836 _M_pi->_M_weak_release();
843 _M_swap(__weak_count& __r) noexcept
845 _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
851 _M_get_use_count() const noexcept
852 {
return _M_pi !=
nullptr ? _M_pi->_M_get_use_count() : 0; }
855 _M_less(
const __weak_count& __rhs)
const noexcept
859 _M_less(
const __shared_count<_Lp>& __rhs)
const noexcept
864 operator==(
const __weak_count& __a,
const __weak_count& __b) noexcept
865 {
return __a._M_pi == __b._M_pi; }
868 friend class __shared_count<_Lp>;
870 _Sp_counted_base<_Lp>* _M_pi;
874 template<_Lock_policy _Lp>
876 __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
879 if (_M_pi !=
nullptr)
880 _M_pi->_M_add_ref_lock();
882 __throw_bad_weak_ptr();
886 template<_Lock_policy _Lp>
888 __shared_count<_Lp>::
889 __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t)
892 if (_M_pi !=
nullptr)
893 if (!_M_pi->_M_add_ref_lock_nothrow())
897 #define __cpp_lib_shared_ptr_arrays 201603 903 template<
typename _Yp_ptr,
typename _Tp_ptr>
904 struct __sp_compatible_with
908 template<
typename _Yp,
typename _Tp>
909 struct __sp_compatible_with<_Yp*, _Tp*>
910 : is_convertible<_Yp*, _Tp*>::type
913 template<
typename _Up,
size_t _Nm>
914 struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
918 template<
typename _Up,
size_t _Nm>
919 struct __sp_compatible_with<_Up(*)[_Nm],
const _Up(*)[]>
923 template<
typename _Up,
size_t _Nm>
924 struct __sp_compatible_with<_Up(*)[_Nm],
volatile _Up(*)[]>
928 template<
typename _Up,
size_t _Nm>
929 struct __sp_compatible_with<_Up(*)[_Nm],
const volatile _Up(*)[]>
934 template<
typename _Up,
size_t _Nm,
typename _Yp,
typename =
void>
935 struct __sp_is_constructible_arrN
939 template<
typename _Up,
size_t _Nm,
typename _Yp>
940 struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
941 : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
945 template<
typename _Up,
typename _Yp,
typename =
void>
946 struct __sp_is_constructible_arr
950 template<
typename _Up,
typename _Yp>
951 struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
952 : is_convertible<_Yp(*)[], _Up(*)[]>::type
956 template<
typename _Tp,
typename _Yp>
957 struct __sp_is_constructible;
960 template<
typename _Up,
size_t _Nm,
typename _Yp>
961 struct __sp_is_constructible<_Up[_Nm], _Yp>
962 : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
966 template<
typename _Up,
typename _Yp>
967 struct __sp_is_constructible<_Up[], _Yp>
968 : __sp_is_constructible_arr<_Up, _Yp>::type
972 template<
typename _Tp,
typename _Yp>
973 struct __sp_is_constructible
974 : is_convertible<_Yp*, _Tp*>::type
979 template<
typename _Tp, _Lock_policy _Lp,
980 bool = is_array<_Tp>::value,
bool = is_void<_Tp>::value>
981 class __shared_ptr_access
984 using element_type = _Tp;
989 __glibcxx_assert(_M_get() !=
nullptr);
994 operator->() const noexcept
996 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1002 _M_get() const noexcept
1003 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
1007 template<
typename _Tp, _Lock_policy _Lp>
1008 class __shared_ptr_access<_Tp, _Lp, false, true>
1011 using element_type = _Tp;
1014 operator->() const noexcept
1016 auto __ptr =
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get();
1017 _GLIBCXX_DEBUG_PEDASSERT(__ptr !=
nullptr);
1023 template<
typename _Tp, _Lock_policy _Lp>
1024 class __shared_ptr_access<_Tp, _Lp, true, false>
1027 using element_type =
typename remove_extent<_Tp>::type;
1029 #if __cplusplus <= 201402L 1030 [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
1034 __glibcxx_assert(_M_get() !=
nullptr);
1038 [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
1040 operator->() const noexcept
1042 _GLIBCXX_DEBUG_PEDASSERT(_M_get() !=
nullptr);
1048 operator[](ptrdiff_t __i)
const 1050 __glibcxx_assert(_M_get() !=
nullptr);
1051 __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
1052 return _M_get()[__i];
1057 _M_get() const noexcept
1058 {
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->
get(); }
1061 template<
typename _Tp, _Lock_policy _Lp>
1063 :
public __shared_ptr_access<_Tp, _Lp>
1066 using element_type =
typename remove_extent<_Tp>::type;
1070 template<
typename _Yp>
1072 =
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
1075 template<
typename _Yp,
typename _Res =
void>
1076 using _Compatible =
typename 1077 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1080 template<
typename _Yp>
1081 using _Assignable = _Compatible<_Yp, __shared_ptr&>;
1084 template<
typename _Yp,
typename _Del,
typename _Res = void,
1085 typename _Ptr =
typename unique_ptr<_Yp, _Del>::pointer>
1086 using _UniqCompatible =
typename enable_if<__and_<
1087 __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
1088 >::value, _Res>::type;
1091 template<
typename _Yp,
typename _Del>
1092 using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
1096 #if __cplusplus > 201402L 1097 using weak_type = __weak_ptr<_Tp, _Lp>;
1100 constexpr __shared_ptr() noexcept
1101 : _M_ptr(0), _M_refcount()
1104 template<
typename _Yp,
typename = _SafeConv<_Yp>>
1106 __shared_ptr(_Yp* __p)
1107 : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
1109 static_assert( !is_void<_Yp>::value,
"incomplete type" );
1110 static_assert(
sizeof(_Yp) > 0,
"incomplete type" );
1111 _M_enable_shared_from_this_with(__p);
1114 template<
typename _Yp,
typename _Deleter,
typename = _SafeConv<_Yp>>
1115 __shared_ptr(_Yp* __p, _Deleter __d)
1116 : _M_ptr(__p), _M_refcount(__p,
std::move(__d))
1118 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1119 "deleter expression d(p) is well-formed");
1120 _M_enable_shared_from_this_with(__p);
1123 template<
typename _Yp,
typename _Deleter,
typename _Alloc,
1124 typename = _SafeConv<_Yp>>
1125 __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
1126 : _M_ptr(__p), _M_refcount(__p,
std::move(__d),
std::move(__a))
1128 static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
1129 "deleter expression d(p) is well-formed");
1130 _M_enable_shared_from_this_with(__p);
1133 template<
typename _Deleter>
1134 __shared_ptr(nullptr_t __p, _Deleter __d)
1135 : _M_ptr(0), _M_refcount(__p,
std::move(__d))
1138 template<
typename _Deleter,
typename _Alloc>
1139 __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
1140 : _M_ptr(0), _M_refcount(__p,
std::move(__d),
std::move(__a))
1143 template<
typename _Yp>
1144 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
1145 element_type* __p) noexcept
1146 : _M_ptr(__p), _M_refcount(__r._M_refcount)
1149 __shared_ptr(
const __shared_ptr&) noexcept =
default;
1150 __shared_ptr& operator=(
const __shared_ptr&) noexcept =
default;
1151 ~__shared_ptr() =
default;
1153 template<
typename _Yp,
typename = _Compatible<_Yp>>
1154 __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1155 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1158 __shared_ptr(__shared_ptr&& __r) noexcept
1159 : _M_ptr(__r._M_ptr), _M_refcount()
1161 _M_refcount._M_swap(__r._M_refcount);
1165 template<
typename _Yp,
typename = _Compatible<_Yp>>
1166 __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1167 : _M_ptr(__r._M_ptr), _M_refcount()
1169 _M_refcount._M_swap(__r._M_refcount);
1173 template<
typename _Yp,
typename = _Compatible<_Yp>>
1174 explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
1175 : _M_refcount(__r._M_refcount)
1179 _M_ptr = __r._M_ptr;
1183 template<
typename _Yp,
typename _Del,
1184 typename = _UniqCompatible<_Yp, _Del>>
1185 __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
1186 : _M_ptr(__r.get()), _M_refcount()
1188 auto __raw = __to_address(__r.get());
1189 _M_refcount = __shared_count<_Lp>(std::move(__r));
1190 _M_enable_shared_from_this_with(__raw);
1193 #if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED 1196 template<
typename _Tp1,
typename _Del,
1197 typename enable_if<__and_<
1198 __not_<is_array<_Tp>>, is_array<_Tp1>,
1199 is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
1200 >::value,
bool>::type =
true>
1201 __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
1202 : _M_ptr(__r.get()), _M_refcount()
1204 auto __raw = __to_address(__r.get());
1205 _M_refcount = __shared_count<_Lp>(std::move(__r));
1206 _M_enable_shared_from_this_with(__raw);
1211 #if _GLIBCXX_USE_DEPRECATED 1212 #pragma GCC diagnostic push 1213 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 1215 template<
typename _Yp,
typename = _Compatible<_Yp>>
1216 __shared_ptr(auto_ptr<_Yp>&& __r);
1217 #pragma GCC diagnostic pop 1220 constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
1222 template<
typename _Yp>
1224 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1226 _M_ptr = __r._M_ptr;
1227 _M_refcount = __r._M_refcount;
1231 #if _GLIBCXX_USE_DEPRECATED 1232 #pragma GCC diagnostic push 1233 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 1234 template<
typename _Yp>
1236 operator=(auto_ptr<_Yp>&& __r)
1238 __shared_ptr(std::move(__r)).swap(*
this);
1241 #pragma GCC diagnostic pop 1245 operator=(__shared_ptr&& __r) noexcept
1247 __shared_ptr(std::move(__r)).swap(*
this);
1253 operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept
1255 __shared_ptr(std::move(__r)).swap(*
this);
1259 template<
typename _Yp,
typename _Del>
1260 _UniqAssignable<_Yp, _Del>
1261 operator=(unique_ptr<_Yp, _Del>&& __r)
1263 __shared_ptr(std::move(__r)).swap(*
this);
1269 { __shared_ptr().swap(*
this); }
1271 template<
typename _Yp>
1276 __glibcxx_assert(__p == 0 || __p != _M_ptr);
1277 __shared_ptr(__p).swap(*
this);
1280 template<
typename _Yp,
typename _Deleter>
1282 reset(_Yp* __p, _Deleter __d)
1283 { __shared_ptr(__p, std::move(__d)).swap(*
this); }
1285 template<
typename _Yp,
typename _Deleter,
typename _Alloc>
1287 reset(_Yp* __p, _Deleter __d, _Alloc __a)
1288 { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*
this); }
1291 get()
const noexcept
1294 explicit operator bool() const
1295 {
return _M_ptr == 0 ? false :
true; }
1298 unique() const noexcept
1299 {
return _M_refcount._M_unique(); }
1302 use_count() const noexcept
1303 {
return _M_refcount._M_get_use_count(); }
1306 swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
1308 std::swap(_M_ptr, __other._M_ptr);
1309 _M_refcount._M_swap(__other._M_refcount);
1312 template<
typename _Tp1>
1314 owner_before(__shared_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1315 {
return _M_refcount._M_less(__rhs._M_refcount); }
1317 template<
typename _Tp1>
1319 owner_before(__weak_ptr<_Tp1, _Lp>
const& __rhs)
const noexcept
1320 {
return _M_refcount._M_less(__rhs._M_refcount); }
1324 template<
typename _Alloc,
typename... _Args>
1325 __shared_ptr(_Sp_make_shared_tag __tag,
const _Alloc& __a,
1327 : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
1333 void* __p = _M_refcount._M_get_deleter(
typeid(__tag));
1335 void* __p = _M_refcount._M_get_deleter(_Sp_make_shared_tag::_S_ti());
1337 _M_ptr =
static_cast<_Tp*
>(__p);
1338 _M_enable_shared_from_this_with(_M_ptr);
1341 template<
typename _Tp1, _Lock_policy _Lp1,
typename _Alloc,
1343 friend __shared_ptr<_Tp1, _Lp1>
1344 __allocate_shared(
const _Alloc& __a, _Args&&... __args);
1348 __shared_ptr(
const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t)
1349 : _M_refcount(__r._M_refcount,
std::nothrow)
1351 _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr :
nullptr;
1354 friend class __weak_ptr<_Tp, _Lp>;
1358 template<
typename _Yp>
1359 using __esft_base_t = decltype(__enable_shared_from_this_base(
1360 std::declval<
const __shared_count<_Lp>&>(),
1361 std::declval<_Yp*>()));
1364 template<
typename _Yp,
typename =
void>
1365 struct __has_esft_base
1368 template<
typename _Yp>
1369 struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
1370 : __not_<is_array<_Tp>> { };
1372 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1373 typename enable_if<__has_esft_base<_Yp2>::value>::type
1374 _M_enable_shared_from_this_with(_Yp* __p) noexcept
1376 if (
auto __base = __enable_shared_from_this_base(_M_refcount, __p))
1377 __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount);
1380 template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
1381 typename enable_if<!__has_esft_base<_Yp2>::value>::type
1382 _M_enable_shared_from_this_with(_Yp*) noexcept
1387 {
return _M_refcount._M_get_deleter(__ti); }
1389 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1390 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1392 template<
typename _Del,
typename _Tp1, _Lock_policy _Lp1>
1393 friend _Del* get_deleter(
const __shared_ptr<_Tp1, _Lp1>&) noexcept;
1395 template<
typename _Del,
typename _Tp1>
1396 friend _Del* get_deleter(
const shared_ptr<_Tp1>&) noexcept;
1398 element_type* _M_ptr;
1399 __shared_count<_Lp> _M_refcount;
1404 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1406 operator==(
const __shared_ptr<_Tp1, _Lp>& __a,
1407 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1408 {
return __a.get() == __b.get(); }
1410 template<
typename _Tp, _Lock_policy _Lp>
1412 operator==(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1415 template<
typename _Tp, _Lock_policy _Lp>
1417 operator==(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1420 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1422 operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
1423 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1424 {
return __a.get() != __b.get(); }
1426 template<
typename _Tp, _Lock_policy _Lp>
1428 operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1429 {
return (
bool)__a; }
1431 template<
typename _Tp, _Lock_policy _Lp>
1433 operator!=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1434 {
return (
bool)__a; }
1436 template<
typename _Tp,
typename _Up, _Lock_policy _Lp>
1438 operator<(const __shared_ptr<_Tp, _Lp>& __a,
1439 const __shared_ptr<_Up, _Lp>& __b) noexcept
1441 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1442 using _Up_elt =
typename __shared_ptr<_Up, _Lp>::element_type;
1443 using _Vp =
typename common_type<_Tp_elt*, _Up_elt*>::type;
1444 return less<_Vp>()(__a.get(), __b.get());
1447 template<
typename _Tp, _Lock_policy _Lp>
1449 operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1451 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1452 return less<_Tp_elt*>()(__a.get(),
nullptr);
1455 template<
typename _Tp, _Lock_policy _Lp>
1457 operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1459 using _Tp_elt =
typename __shared_ptr<_Tp, _Lp>::element_type;
1460 return less<_Tp_elt*>()(
nullptr, __a.get());
1463 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1465 operator<=(const __shared_ptr<_Tp1, _Lp>& __a,
1466 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1467 {
return !(__b < __a); }
1469 template<
typename _Tp, _Lock_policy _Lp>
1471 operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1472 {
return !(
nullptr < __a); }
1474 template<
typename _Tp, _Lock_policy _Lp>
1476 operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
1477 {
return !(__a <
nullptr); }
1479 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1481 operator>(
const __shared_ptr<_Tp1, _Lp>& __a,
1482 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1483 {
return (__b < __a); }
1485 template<
typename _Tp, _Lock_policy _Lp>
1487 operator>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1488 {
return nullptr < __a; }
1490 template<
typename _Tp, _Lock_policy _Lp>
1492 operator>(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1493 {
return __a <
nullptr; }
1495 template<
typename _Tp1,
typename _Tp2, _Lock_policy _Lp>
1497 operator>=(
const __shared_ptr<_Tp1, _Lp>& __a,
1498 const __shared_ptr<_Tp2, _Lp>& __b) noexcept
1499 {
return !(__a < __b); }
1501 template<
typename _Tp, _Lock_policy _Lp>
1503 operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
1504 {
return !(__a <
nullptr); }
1506 template<
typename _Tp, _Lock_policy _Lp>
1508 operator>=(nullptr_t,
const __shared_ptr<_Tp, _Lp>& __a) noexcept
1509 {
return !(
nullptr < __a); }
1511 template<
typename _Sp>
1512 struct _Sp_less :
public binary_function<_Sp, _Sp, bool>
1515 operator()(
const _Sp& __lhs,
const _Sp& __rhs)
const noexcept
1517 typedef typename _Sp::element_type element_type;
1522 template<
typename _Tp, _Lock_policy _Lp>
1523 struct less<__shared_ptr<_Tp, _Lp>>
1524 :
public _Sp_less<__shared_ptr<_Tp, _Lp>>
1528 template<
typename _Tp, _Lock_policy _Lp>
1530 swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
1540 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1541 inline __shared_ptr<_Tp, _Lp>
1542 static_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1544 using _Sp = __shared_ptr<_Tp, _Lp>;
1545 return _Sp(__r, static_cast<typename _Sp::element_type*>(__r.get()));
1553 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1554 inline __shared_ptr<_Tp, _Lp>
1555 const_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1557 using _Sp = __shared_ptr<_Tp, _Lp>;
1558 return _Sp(__r, const_cast<typename _Sp::element_type*>(__r.get()));
1566 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1567 inline __shared_ptr<_Tp, _Lp>
1568 dynamic_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1570 using _Sp = __shared_ptr<_Tp, _Lp>;
1571 if (
auto* __p = dynamic_cast<typename _Sp::element_type*>(__r.get()))
1572 return _Sp(__r, __p);
1576 #if __cplusplus > 201402L 1577 template<
typename _Tp,
typename _Tp1, _Lock_policy _Lp>
1578 inline __shared_ptr<_Tp, _Lp>
1579 reinterpret_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
1581 using _Sp = __shared_ptr<_Tp, _Lp>;
1582 return _Sp(__r, reinterpret_cast<typename _Sp::element_type*>(__r.get()));
1586 template<
typename _Tp, _Lock_policy _Lp>
1589 template<
typename _Yp,
typename _Res =
void>
1590 using _Compatible =
typename 1591 enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
1594 template<
typename _Yp>
1595 using _Assignable = _Compatible<_Yp, __weak_ptr&>;
1598 using element_type =
typename remove_extent<_Tp>::type;
1600 constexpr __weak_ptr() noexcept
1601 : _M_ptr(
nullptr), _M_refcount()
1604 __weak_ptr(
const __weak_ptr&) noexcept =
default;
1606 ~__weak_ptr() =
default;
1622 template<
typename _Yp,
typename = _Compatible<_Yp>>
1623 __weak_ptr(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1624 : _M_refcount(__r._M_refcount)
1625 { _M_ptr = __r.lock().get(); }
1627 template<
typename _Yp,
typename = _Compatible<_Yp>>
1628 __weak_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1629 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
1632 __weak_ptr(__weak_ptr&& __r) noexcept
1633 : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount))
1634 { __r._M_ptr =
nullptr; }
1636 template<
typename _Yp,
typename = _Compatible<_Yp>>
1637 __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1638 : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount))
1639 { __r._M_ptr =
nullptr; }
1642 operator=(
const __weak_ptr& __r) noexcept =
default;
1644 template<
typename _Yp>
1646 operator=(
const __weak_ptr<_Yp, _Lp>& __r) noexcept
1648 _M_ptr = __r.lock().get();
1649 _M_refcount = __r._M_refcount;
1653 template<
typename _Yp>
1655 operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
1657 _M_ptr = __r._M_ptr;
1658 _M_refcount = __r._M_refcount;
1663 operator=(__weak_ptr&& __r) noexcept
1665 _M_ptr = __r._M_ptr;
1666 _M_refcount = std::move(__r._M_refcount);
1667 __r._M_ptr =
nullptr;
1671 template<
typename _Yp>
1673 operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept
1675 _M_ptr = __r.lock().get();
1676 _M_refcount = std::move(__r._M_refcount);
1677 __r._M_ptr =
nullptr;
1681 __shared_ptr<_Tp, _Lp>
1682 lock() const noexcept
1683 {
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
1686 use_count() const noexcept
1687 {
return _M_refcount._M_get_use_count(); }
1690 expired() const noexcept
1691 {
return _M_refcount._M_get_use_count() == 0; }
1693 template<
typename _Tp1>
1695 owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1696 {
return _M_refcount._M_less(__rhs._M_refcount); }
1698 template<
typename _Tp1>
1700 owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs)
const noexcept
1701 {
return _M_refcount._M_less(__rhs._M_refcount); }
1705 { __weak_ptr().swap(*
this); }
1708 swap(__weak_ptr& __s) noexcept
1710 std::swap(_M_ptr, __s._M_ptr);
1711 _M_refcount._M_swap(__s._M_refcount);
1717 _M_assign(_Tp* __ptr,
const __shared_count<_Lp>& __refcount) noexcept
1719 if (use_count() == 0)
1722 _M_refcount = __refcount;
1726 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __shared_ptr;
1727 template<
typename _Tp1, _Lock_policy _Lp1>
friend class __weak_ptr;
1728 friend class __enable_shared_from_this<_Tp, _Lp>;
1729 friend class enable_shared_from_this<_Tp>;
1731 element_type* _M_ptr;
1732 __weak_count<_Lp> _M_refcount;
1736 template<
typename _Tp, _Lock_policy _Lp>
1738 swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
1741 template<
typename _Tp,
typename _Tp1>
1742 struct _Sp_owner_less :
public binary_function<_Tp, _Tp, bool>
1745 operator()(
const _Tp& __lhs,
const _Tp& __rhs)
const noexcept
1746 {
return __lhs.owner_before(__rhs); }
1749 operator()(
const _Tp& __lhs,
const _Tp1& __rhs)
const noexcept
1750 {
return __lhs.owner_before(__rhs); }
1753 operator()(
const _Tp1& __lhs,
const _Tp& __rhs)
const noexcept
1754 {
return __lhs.owner_before(__rhs); }
1758 struct _Sp_owner_less<void, void>
1760 template<
typename _Tp,
typename _Up>
1762 operator()(
const _Tp& __lhs,
const _Up& __rhs)
const noexcept
1763 -> decltype(__lhs.owner_before(__rhs))
1764 {
return __lhs.owner_before(__rhs); }
1766 using is_transparent = void;
1769 template<
typename _Tp, _Lock_policy _Lp>
1770 struct owner_less<__shared_ptr<_Tp, _Lp>>
1771 :
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
1774 template<
typename _Tp, _Lock_policy _Lp>
1775 struct owner_less<__weak_ptr<_Tp, _Lp>>
1776 :
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
1780 template<
typename _Tp, _Lock_policy _Lp>
1781 class __enable_shared_from_this
1784 constexpr __enable_shared_from_this() noexcept { }
1786 __enable_shared_from_this(
const __enable_shared_from_this&) noexcept { }
1788 __enable_shared_from_this&
1789 operator=(
const __enable_shared_from_this&) noexcept
1792 ~__enable_shared_from_this() { }
1795 __shared_ptr<_Tp, _Lp>
1797 {
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
1799 __shared_ptr<const _Tp, _Lp>
1800 shared_from_this()
const 1801 {
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
1803 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1804 __weak_ptr<_Tp, _Lp>
1805 weak_from_this() noexcept
1806 {
return this->_M_weak_this; }
1808 __weak_ptr<const _Tp, _Lp>
1809 weak_from_this() const noexcept
1810 {
return this->_M_weak_this; }
1814 template<
typename _Tp1>
1816 _M_weak_assign(_Tp1* __p,
const __shared_count<_Lp>& __n)
const noexcept
1817 { _M_weak_this._M_assign(__p, __n); }
1819 friend const __enable_shared_from_this*
1820 __enable_shared_from_this_base(
const __shared_count<_Lp>&,
1821 const __enable_shared_from_this* __p)
1824 template<
typename, _Lock_policy>
1825 friend class __shared_ptr;
1827 mutable __weak_ptr<_Tp, _Lp> _M_weak_this;
1830 template<
typename _Tp, _Lock_policy _Lp,
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_make_shared_tag(), __a,
1835 std::forward<_Args>(__args)...);
1838 template<
typename _Tp, _Lock_policy _Lp,
typename... _Args>
1839 inline __shared_ptr<_Tp, _Lp>
1840 __make_shared(_Args&&... __args)
1842 typedef typename std::remove_const<_Tp>::type _Tp_nc;
1844 std::forward<_Args>(__args)...);
1848 template<
typename _Tp, _Lock_policy _Lp>
1849 struct hash<__shared_ptr<_Tp, _Lp>>
1850 :
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
1853 operator()(
const __shared_ptr<_Tp, _Lp>& __s)
const noexcept
1860 _GLIBCXX_END_NAMESPACE_VERSION
1863 #endif // _SHARED_PTR_BASE_H
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
Exception possibly thrown by shared_ptr.
Primary class template hash.
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.
Base class for all library exceptions.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
__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.
One of the comparison functors.
ISO C++ entities toplevel namespace is std.
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.
20.7.1.2 unique_ptr for single objects.
A simple smart pointer providing strict ownership semantics.
static void destroy(_Alloc &__a, _Tp *__p)
Destroy an object of type _Tp.
virtual char const * what() const noexcept
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.