49 #ifndef _SHARED_PTR_BASE_H    50 #define _SHARED_PTR_BASE_H 1    58 namespace std _GLIBCXX_VISIBILITY(default)
    60 _GLIBCXX_BEGIN_NAMESPACE_VERSION
    62 #if _GLIBCXX_USE_DEPRECATED    63 #pragma GCC diagnostic push    64 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"    65   template<
typename> 
class auto_ptr;
    66 #pragma GCC diagnostic pop    76     virtual char const* 
what() 
const noexcept;
    83   __throw_bad_weak_ptr()
    86   using __gnu_cxx::_Lock_policy;
    87   using __gnu_cxx::__default_lock_policy;
    88   using __gnu_cxx::_S_single;
    89   using __gnu_cxx::_S_mutex;
    90   using __gnu_cxx::_S_atomic;
    93   template<_Lock_policy _Lp>
    98       enum { _S_need_barriers = 0 };
   102     class _Mutex_base<_S_mutex>
   103     : 
public __gnu_cxx::__mutex
   109       enum { _S_need_barriers = 1 };
   112   template<_Lock_policy _Lp = __default_lock_policy>
   113     class _Sp_counted_base
   114     : 
public _Mutex_base<_Lp>
   117       _Sp_counted_base() noexcept
   118       : _M_use_count(1), _M_weak_count(1) { }
   121       ~_Sp_counted_base() noexcept
   127       _M_dispose() noexcept = 0;
   131       _M_destroy() noexcept
   139       { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); }
   145       _M_add_ref_lock_nothrow();
   148       _M_release() noexcept
   151         _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
   152         if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1)
   154             _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count);
   160             if (_Mutex_base<_Lp>::_S_need_barriers)
   162                 __atomic_thread_fence (__ATOMIC_ACQ_REL);
   166             _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
   167             if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count,
   170                 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
   177       _M_weak_add_ref() noexcept
   178       { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
   181       _M_weak_release() noexcept
   184         _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
   185         if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1)
   187             _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count);
   188             if (_Mutex_base<_Lp>::_S_need_barriers)
   192                 __atomic_thread_fence (__ATOMIC_ACQ_REL);
   199       _M_get_use_count() const noexcept
   203         return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
   207       _Sp_counted_base(_Sp_counted_base 
const&) = 
delete;
   208       _Sp_counted_base& operator=(_Sp_counted_base 
const&) = 
delete;
   210       _Atomic_word  _M_use_count;     
   211       _Atomic_word  _M_weak_count;    
   216     _Sp_counted_base<_S_single>::
   219       if (_M_use_count == 0)
   220         __throw_bad_weak_ptr();
   226     _Sp_counted_base<_S_mutex>::
   230       if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
   233           __throw_bad_weak_ptr();
   239     _Sp_counted_base<_S_atomic>::
   243       _Atomic_word __count = _M_get_use_count();
   247             __throw_bad_weak_ptr();
   251       while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
   252                                           true, __ATOMIC_ACQ_REL,
   258     _Sp_counted_base<_S_single>::
   259     _M_add_ref_lock_nothrow()
   261       if (_M_use_count == 0)
   269     _Sp_counted_base<_S_mutex>::
   270     _M_add_ref_lock_nothrow()
   273       if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
   283     _Sp_counted_base<_S_atomic>::
   284     _M_add_ref_lock_nothrow()
   287       _Atomic_word __count = _M_get_use_count();
   295       while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
   296                                           true, __ATOMIC_ACQ_REL,
   303     _Sp_counted_base<_S_single>::_M_add_ref_copy()
   308     _Sp_counted_base<_S_single>::_M_release() noexcept
   310       if (--_M_use_count == 0)
   313           if (--_M_weak_count == 0)
   320     _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
   325     _Sp_counted_base<_S_single>::_M_weak_release() noexcept
   327       if (--_M_weak_count == 0)
   333     _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
   334     { 
return _M_use_count; }
   338   template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
   341   template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
   344   template<
typename _Tp, _Lock_policy _Lp = __default_lock_policy>
   345     class __enable_shared_from_this;
   347   template<
typename _Tp>
   350   template<
typename _Tp>
   353   template<
typename _Tp>
   356   template<
typename _Tp>
   357     class enable_shared_from_this;
   359   template<_Lock_policy _Lp = __default_lock_policy>
   362   template<_Lock_policy _Lp = __default_lock_policy>
   363     class __shared_count;
   367   template<
typename _Ptr, _Lock_policy _Lp>
   368     class _Sp_counted_ptr final : 
public _Sp_counted_base<_Lp>
   372       _Sp_counted_ptr(_Ptr __p) noexcept
   376       _M_dispose() noexcept
   380       _M_destroy() noexcept
   387       _Sp_counted_ptr(
const _Sp_counted_ptr&) = 
delete;
   388       _Sp_counted_ptr& operator=(
const _Sp_counted_ptr&) = 
delete;
   396     _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
   400     _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
   404     _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
   406   template<
int _Nm, 
typename _Tp,
   407            bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
   408     struct _Sp_ebo_helper;
   411   template<
int _Nm, 
typename _Tp>
   412     struct _Sp_ebo_helper<_Nm, _Tp, true> : 
private _Tp
   414       explicit _Sp_ebo_helper(
const _Tp& __tp) : _Tp(__tp) { }
   415       explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { }
   418       _S_get(_Sp_ebo_helper& __eboh) { 
return static_cast<_Tp&>(__eboh); }
   422   template<
int _Nm, 
typename _Tp>
   423     struct _Sp_ebo_helper<_Nm, _Tp, false>
   425       explicit _Sp_ebo_helper(
const _Tp& __tp) : _M_tp(__tp) { }
   426       explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
   429       _S_get(_Sp_ebo_helper& __eboh)
   430       { 
return __eboh._M_tp; }
   437   template<
typename _Ptr, 
typename _Deleter, 
typename _Alloc, _Lock_policy _Lp>
   438     class _Sp_counted_deleter final : 
public _Sp_counted_base<_Lp>
   440       class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc>
   442         typedef _Sp_ebo_helper<0, _Deleter>     _Del_base;
   443         typedef _Sp_ebo_helper<1, _Alloc>       _Alloc_base;
   446         _Impl(_Ptr __p, _Deleter __d, 
const _Alloc& __a) noexcept
   447         : _M_ptr(__p), _Del_base(std::move(__d)), _Alloc_base(__a)
   450         _Deleter& _M_del() noexcept { 
return _Del_base::_S_get(*
this); }
   451         _Alloc& _M_alloc() noexcept { 
return _Alloc_base::_S_get(*
this); }
   457       using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;
   460       _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept
   461       : _M_impl(__p, std::move(__d), _Alloc()) { }
   464       _Sp_counted_deleter(_Ptr __p, _Deleter __d, 
const _Alloc& __a) noexcept
   465       : _M_impl(__p, std::move(__d), __a) { }
   467       ~_Sp_counted_deleter() noexcept { }
   470       _M_dispose() noexcept
   471       { _M_impl._M_del()(_M_impl._M_ptr); }
   474       _M_destroy() noexcept
   476         __allocator_type __a(_M_impl._M_alloc());
   477         __allocated_ptr<__allocator_type> __guard_ptr{ __a, 
this };
   478         this->~_Sp_counted_deleter();
   487         return __ti == 
typeid(_Deleter)
   501   struct _Sp_make_shared_tag
   504     template<
typename _Tp, 
typename _Alloc, _Lock_policy _Lp>
   505       friend class _Sp_counted_ptr_inplace;
   507     static const type_info&
   508     _S_ti() noexcept _GLIBCXX_VISIBILITY(default)
   510       alignas(type_info) 
static constexpr 
char __tag[
sizeof(type_info)] = { };
   511       return reinterpret_cast<const type_info&>(__tag);
   515   template<
typename _Alloc>
   516     struct _Sp_alloc_shared_tag
   521   template<
typename _Tp, 
typename _Alloc, _Lock_policy _Lp>
   522     class _Sp_counted_ptr_inplace final : 
public _Sp_counted_base<_Lp>
   524       class _Impl : _Sp_ebo_helper<0, _Alloc>
   526         typedef _Sp_ebo_helper<0, _Alloc>       _A_base;
   529         explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { }
   531         _Alloc& _M_alloc() noexcept { 
return _A_base::_S_get(*
this); }
   533         __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
   537       using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
   539       template<
typename... _Args>
   540         _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
   546               std::forward<_Args>(__args)...); 
   549       ~_Sp_counted_ptr_inplace() noexcept { }
   552       _M_dispose() noexcept
   559       _M_destroy() noexcept
   561         __allocator_type __a(_M_impl._M_alloc());
   562         __allocated_ptr<__allocator_type> __guard_ptr{ __a, 
this };
   563         this->~_Sp_counted_ptr_inplace();
   567       friend class __shared_count<_Lp>; 
   576         if (&__ti == &_Sp_make_shared_tag::_S_ti())
   577           return const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
   581         else if (__ti == 
typeid(_Sp_make_shared_tag))
   582           return const_cast<typename remove_cv<_Tp>::type*
>(_M_ptr());
   592       _Tp* _M_ptr() noexcept { 
return _M_impl._M_storage._M_ptr(); }
   598   struct __sp_array_delete
   600     template<
typename _Yp>
   601       void operator()(_Yp* __p)
 const { 
delete[] __p; }
   604   template<_Lock_policy _Lp>
   607       template<
typename _Tp>
   608         struct __not_alloc_shared_tag { 
using type = void; };
   610       template<
typename _Tp>
   611         struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { };
   614       constexpr __shared_count() noexcept : _M_pi(0)
   617       template<
typename _Ptr>
   619         __shared_count(_Ptr __p) : _M_pi(0)
   623               _M_pi = 
new _Sp_counted_ptr<_Ptr, _Lp>(__p);
   628               __throw_exception_again;
   632       template<
typename _Ptr>
   634         : __shared_count(__p)
   637       template<
typename _Ptr>
   639         : __shared_count(__p, __sp_array_delete{}, allocator<void>())
   642       template<
typename _Ptr, 
typename _Deleter,
   643                typename = 
typename __not_alloc_shared_tag<_Deleter>::type>
   644         __shared_count(_Ptr __p, _Deleter __d)
   645         : __shared_count(__p, 
std::move(__d), allocator<void>())
   648       template<
typename _Ptr, 
typename _Deleter, 
typename _Alloc,
   649                typename = 
typename __not_alloc_shared_tag<_Deleter>::type>
   650         __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0)
   652           typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type;
   655               typename _Sp_cd_type::__allocator_type __a2(__a);
   657               _Sp_cd_type* __mem = __guard.get();
   658               ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a));
   665               __throw_exception_again;
   669       template<
typename _Tp, 
typename _Alloc, 
typename... _Args>
   670         __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a,
   673           typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
   674           typename _Sp_cp_type::__allocator_type __a2(__a._M_a);
   676           _Sp_cp_type* __mem = __guard.get();
   677           auto __pi = ::new (__mem)
   678             _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
   681           __p = __pi->_M_ptr();
   684 #if _GLIBCXX_USE_DEPRECATED   685 #pragma GCC diagnostic push   686 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"   688       template<
typename _Tp>
   691 #pragma GCC diagnostic pop   695       template<
typename _Tp, 
typename _Del>
   701           if (__r.get() == 
nullptr)
   704           using _Ptr = 
typename unique_ptr<_Tp, _Del>::pointer;
   705           using _Del2 = 
typename conditional<is_reference<_Del>::value,
   706               reference_wrapper<typename remove_reference<_Del>::type>,
   709             = _Sp_counted_deleter<_Ptr, _Del2, allocator<void>, _Lp>;
   710           using _Alloc = allocator<_Sp_cd_type>;
   711           using _Alloc_traits = allocator_traits<_Alloc>;
   713           _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1);
   714           _Alloc_traits::construct(__a, __mem, __r.release(),
   720       explicit __shared_count(
const __weak_count<_Lp>& __r);
   723       explicit __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t);
   725       ~__shared_count() noexcept
   727         if (_M_pi != 
nullptr)
   731       __shared_count(
const __shared_count& __r) noexcept
   735           _M_pi->_M_add_ref_copy();
   739       operator=(
const __shared_count& __r) noexcept
   741         _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
   745               __tmp->_M_add_ref_copy();
   754       _M_swap(__shared_count& __r) noexcept
   756         _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
   762       _M_get_use_count() const noexcept
   763       { 
return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
   766       _M_unique() const noexcept
   767       { 
return this->_M_get_use_count() == 1; }
   771       { 
return _M_pi ? _M_pi->_M_get_deleter(__ti) : 
nullptr; }
   774       _M_less(
const __shared_count& __rhs) 
const noexcept
   778       _M_less(
const __weak_count<_Lp>& __rhs) 
const noexcept
   783       operator==(
const __shared_count& __a, 
const __shared_count& __b) noexcept
   784       { 
return __a._M_pi == __b._M_pi; }
   787       friend class __weak_count<_Lp>;
   789       _Sp_counted_base<_Lp>*  _M_pi;
   793   template<_Lock_policy _Lp>
   797       constexpr __weak_count() noexcept : _M_pi(
nullptr)
   800       __weak_count(
const __shared_count<_Lp>& __r) noexcept
   803         if (_M_pi != 
nullptr)
   804           _M_pi->_M_weak_add_ref();
   807       __weak_count(
const __weak_count& __r) noexcept
   810         if (_M_pi != 
nullptr)
   811           _M_pi->_M_weak_add_ref();
   814       __weak_count(__weak_count&& __r) noexcept
   816       { __r._M_pi = 
nullptr; }
   818       ~__weak_count() noexcept
   820         if (_M_pi != 
nullptr)
   821           _M_pi->_M_weak_release();
   825       operator=(
const __shared_count<_Lp>& __r) noexcept
   827         _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
   828         if (__tmp != 
nullptr)
   829           __tmp->_M_weak_add_ref();
   830         if (_M_pi != 
nullptr)
   831           _M_pi->_M_weak_release();
   837       operator=(
const __weak_count& __r) noexcept
   839         _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
   840         if (__tmp != 
nullptr)
   841           __tmp->_M_weak_add_ref();
   842         if (_M_pi != 
nullptr)
   843           _M_pi->_M_weak_release();
   849       operator=(__weak_count&& __r) noexcept
   851         if (_M_pi != 
nullptr)
   852           _M_pi->_M_weak_release();
   859       _M_swap(__weak_count& __r) noexcept
   861         _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
   867       _M_get_use_count() const noexcept
   868       { 
return _M_pi != 
nullptr ? _M_pi->_M_get_use_count() : 0; }
   871       _M_less(
const __weak_count& __rhs) 
const noexcept
   875       _M_less(
const __shared_count<_Lp>& __rhs) 
const noexcept
   880       operator==(
const __weak_count& __a, 
const __weak_count& __b) noexcept
   881       { 
return __a._M_pi == __b._M_pi; }
   884       friend class __shared_count<_Lp>;
   886       _Sp_counted_base<_Lp>*  _M_pi;
   890   template<_Lock_policy _Lp>
   892     __shared_count<_Lp>::__shared_count(
const __weak_count<_Lp>& __r)
   895       if (_M_pi != 
nullptr)
   896         _M_pi->_M_add_ref_lock();
   898         __throw_bad_weak_ptr();
   902   template<_Lock_policy _Lp>
   904     __shared_count<_Lp>::
   905     __shared_count(
const __weak_count<_Lp>& __r, std::nothrow_t)
   908       if (_M_pi != 
nullptr)
   909         if (!_M_pi->_M_add_ref_lock_nothrow())
   913 #define __cpp_lib_shared_ptr_arrays 201603   919   template<
typename _Yp_ptr, 
typename _Tp_ptr>
   920     struct __sp_compatible_with
   924   template<
typename _Yp, 
typename _Tp>
   925     struct __sp_compatible_with<_Yp*, _Tp*>
   926     : is_convertible<_Yp*, _Tp*>::type
   929   template<
typename _Up, 
size_t _Nm>
   930     struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]>
   934   template<
typename _Up, 
size_t _Nm>
   935     struct __sp_compatible_with<_Up(*)[_Nm], 
const _Up(*)[]>
   939   template<
typename _Up, 
size_t _Nm>
   940     struct __sp_compatible_with<_Up(*)[_Nm], 
volatile _Up(*)[]>
   944   template<
typename _Up, 
size_t _Nm>
   945     struct __sp_compatible_with<_Up(*)[_Nm], 
const volatile _Up(*)[]>
   950   template<
typename _Up, 
size_t _Nm, 
typename _Yp, 
typename = 
void>
   951     struct __sp_is_constructible_arrN
   955   template<
typename _Up, 
size_t _Nm, 
typename _Yp>
   956     struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>>
   957     : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type
   961   template<
typename _Up, 
typename _Yp, 
typename = 
void>
   962     struct __sp_is_constructible_arr
   966   template<
typename _Up, 
typename _Yp>
   967     struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>>
   968     : is_convertible<_Yp(*)[], _Up(*)[]>::type
   972   template<
typename _Tp, 
typename _Yp>
   973     struct __sp_is_constructible;
   976   template<
typename _Up, 
size_t _Nm, 
typename _Yp>
   977     struct __sp_is_constructible<_Up[_Nm], _Yp>
   978     : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type
   982   template<
typename _Up, 
typename _Yp>
   983     struct __sp_is_constructible<_Up[], _Yp>
   984     : __sp_is_constructible_arr<_Up, _Yp>::type
   988   template<
typename _Tp, 
typename _Yp>
   989     struct __sp_is_constructible
   990     : is_convertible<_Yp*, _Tp*>::type
   995   template<
typename _Tp, _Lock_policy _Lp,
   996            bool = is_array<_Tp>::value, 
bool = is_void<_Tp>::value>
   997     class __shared_ptr_access
  1000       using element_type = _Tp;
  1005         __glibcxx_assert(_M_get() != 
nullptr);
  1010       operator->() const noexcept
  1012         _GLIBCXX_DEBUG_PEDASSERT(_M_get() != 
nullptr);
  1018       _M_get() const noexcept
  1019       { 
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
  1023   template<
typename _Tp, _Lock_policy _Lp>
  1024     class __shared_ptr_access<_Tp, _Lp, false, true>
  1027       using element_type = _Tp;
  1030       operator->() const noexcept
  1032         auto __ptr = 
static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get();
  1033         _GLIBCXX_DEBUG_PEDASSERT(__ptr != 
nullptr);
  1039   template<
typename _Tp, _Lock_policy _Lp>
  1040     class __shared_ptr_access<_Tp, _Lp, true, false>
  1043       using element_type = 
typename remove_extent<_Tp>::type;
  1045 #if __cplusplus <= 201402L  1046       [[__deprecated__(
"shared_ptr<T[]>::operator* is absent from C++17")]]
  1050         __glibcxx_assert(_M_get() != 
nullptr);
  1054       [[__deprecated__(
"shared_ptr<T[]>::operator-> is absent from C++17")]]
  1056       operator->() const noexcept
  1058         _GLIBCXX_DEBUG_PEDASSERT(_M_get() != 
nullptr);
  1064       operator[](ptrdiff_t __i)
 const  1066         __glibcxx_assert(_M_get() != 
nullptr);
  1067         __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value);
  1068         return _M_get()[__i];
  1073       _M_get() const noexcept
  1074       { 
return static_cast<const __shared_ptr<_Tp, _Lp>*
>(
this)->get(); }
  1077   template<
typename _Tp, _Lock_policy _Lp>
  1079     : 
public __shared_ptr_access<_Tp, _Lp>
  1082       using element_type = 
typename remove_extent<_Tp>::type;
  1086       template<
typename _Yp>
  1088           = 
typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type;
  1091       template<
typename _Yp, 
typename _Res = 
void>
  1092         using _Compatible = 
typename  1093           enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type;
  1096       template<
typename _Yp>
  1097         using _Assignable = _Compatible<_Yp, __shared_ptr&>;
  1100       template<
typename _Yp, 
typename _Del, 
typename _Res = void,
  1101                typename _Ptr = 
typename unique_ptr<_Yp, _Del>::pointer>
  1102         using _UniqCompatible = 
typename enable_if<__and_<
  1103           __sp_compatible_with<_Yp*, _Tp*>, is_convertible<_Ptr, element_type*>
  1104           >::value, _Res>::type;
  1107       template<
typename _Yp, 
typename _Del>
  1108         using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>;
  1112 #if __cplusplus > 201402L  1113       using weak_type = __weak_ptr<_Tp, _Lp>;
  1116       constexpr __shared_ptr() noexcept
  1117       : _M_ptr(0), _M_refcount()
  1120       template<
typename _Yp, 
typename = _SafeConv<_Yp>>
  1122         __shared_ptr(_Yp* __p)
  1123         : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type())
  1125           static_assert( !is_void<_Yp>::value, 
"incomplete type" );
  1126           static_assert( 
sizeof(_Yp) > 0, 
"incomplete type" );
  1127           _M_enable_shared_from_this_with(__p);
  1130       template<
typename _Yp, 
typename _Deleter, 
typename = _SafeConv<_Yp>>
  1131         __shared_ptr(_Yp* __p, _Deleter __d)
  1132         : _M_ptr(__p), _M_refcount(__p, 
std::move(__d))
  1134           static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
  1135               "deleter expression d(p) is well-formed");
  1136           _M_enable_shared_from_this_with(__p);
  1139       template<
typename _Yp, 
typename _Deleter, 
typename _Alloc,
  1140                typename = _SafeConv<_Yp>>
  1141         __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a)
  1142         : _M_ptr(__p), _M_refcount(__p, 
std::move(__d), 
std::move(__a))
  1144           static_assert(__is_invocable<_Deleter&, _Yp*&>::value,
  1145               "deleter expression d(p) is well-formed");
  1146           _M_enable_shared_from_this_with(__p);
  1149       template<
typename _Deleter>
  1150         __shared_ptr(nullptr_t __p, _Deleter __d)
  1151         : _M_ptr(0), _M_refcount(__p, 
std::move(__d))
  1154       template<
typename _Deleter, 
typename _Alloc>
  1155         __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
  1156         : _M_ptr(0), _M_refcount(__p, 
std::move(__d), 
std::move(__a))
  1159       template<
typename _Yp>
  1160         __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r,
  1161                      element_type* __p) noexcept
  1162         : _M_ptr(__p), _M_refcount(__r._M_refcount) 
  1165       __shared_ptr(
const __shared_ptr&) noexcept = 
default;
  1166       __shared_ptr& operator=(
const __shared_ptr&) noexcept = 
default;
  1167       ~__shared_ptr() = 
default;
  1169       template<
typename _Yp, 
typename = _Compatible<_Yp>>
  1170         __shared_ptr(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
  1171         : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
  1174       __shared_ptr(__shared_ptr&& __r) noexcept
  1175       : _M_ptr(__r._M_ptr), _M_refcount()
  1177         _M_refcount._M_swap(__r._M_refcount);
  1181       template<
typename _Yp, 
typename = _Compatible<_Yp>>
  1182         __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept
  1183         : _M_ptr(__r._M_ptr), _M_refcount()
  1185           _M_refcount._M_swap(__r._M_refcount);
  1189       template<
typename _Yp, 
typename = _Compatible<_Yp>>
  1190         explicit __shared_ptr(
const __weak_ptr<_Yp, _Lp>& __r)
  1191         : _M_refcount(__r._M_refcount) 
  1195           _M_ptr = __r._M_ptr;
  1199       template<
typename _Yp, 
typename _Del,
  1200                typename = _UniqCompatible<_Yp, _Del>>
  1201         __shared_ptr(unique_ptr<_Yp, _Del>&& __r)
  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);
  1209 #if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED  1212       template<
typename _Tp1, 
typename _Del,
  1213                typename enable_if<__and_<
  1214                  __not_<is_array<_Tp>>, is_array<_Tp1>,
  1215                  is_convertible<typename unique_ptr<_Tp1, _Del>::pointer, _Tp*>
  1216                >::value, 
bool>::type = 
true>
  1217         __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete)
  1218         : _M_ptr(__r.get()), _M_refcount()
  1220           auto __raw = __to_address(__r.get());
  1221           _M_refcount = __shared_count<_Lp>(std::move(__r));
  1222           _M_enable_shared_from_this_with(__raw);
  1227 #if _GLIBCXX_USE_DEPRECATED  1228 #pragma GCC diagnostic push  1229 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"  1231       template<
typename _Yp, 
typename = _Compatible<_Yp>>
  1232         __shared_ptr(auto_ptr<_Yp>&& __r);
  1233 #pragma GCC diagnostic pop  1236       constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { }
  1238       template<
typename _Yp>
  1240         operator=(
const __shared_ptr<_Yp, _Lp>& __r) noexcept
  1242           _M_ptr = __r._M_ptr;
  1243           _M_refcount = __r._M_refcount; 
  1247 #if _GLIBCXX_USE_DEPRECATED  1248 #pragma GCC diagnostic push  1249 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"  1250       template<
typename _Yp>
  1252         operator=(auto_ptr<_Yp>&& __r)
  1254           __shared_ptr(std::move(__r)).swap(*
this);
  1257 #pragma GCC diagnostic pop  1261       operator=(__shared_ptr&& __r) noexcept
  1263         __shared_ptr(std::move(__r)).swap(*
this);
  1269         operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept
  1271           __shared_ptr(std::move(__r)).swap(*
this);
  1275       template<
typename _Yp, 
typename _Del>
  1276         _UniqAssignable<_Yp, _Del>
  1277         operator=(unique_ptr<_Yp, _Del>&& __r)
  1279           __shared_ptr(std::move(__r)).swap(*
this);
  1285       { __shared_ptr().swap(*
this); }
  1287       template<
typename _Yp>
  1292           __glibcxx_assert(__p == 0 || __p != _M_ptr);
  1293           __shared_ptr(__p).swap(*
this);
  1296       template<
typename _Yp, 
typename _Deleter>
  1298         reset(_Yp* __p, _Deleter __d)
  1299         { __shared_ptr(__p, std::move(__d)).swap(*
this); }
  1301       template<
typename _Yp, 
typename _Deleter, 
typename _Alloc>
  1303         reset(_Yp* __p, _Deleter __d, _Alloc __a)
  1304         { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*
this); }
  1307       get() const noexcept
  1310       explicit operator bool() const 
  1311       { 
return _M_ptr == 0 ? false : 
true; }
  1314       unique() const noexcept
  1315       { 
return _M_refcount._M_unique(); }
  1318       use_count() const noexcept
  1319       { 
return _M_refcount._M_get_use_count(); }
  1322       swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
  1324         std::swap(_M_ptr, __other._M_ptr);
  1325         _M_refcount._M_swap(__other._M_refcount);
  1328       template<
typename _Tp1>
  1330         owner_before(__shared_ptr<_Tp1, _Lp> 
const& __rhs) 
const noexcept
  1331         { 
return _M_refcount._M_less(__rhs._M_refcount); }
  1333       template<
typename _Tp1>
  1335         owner_before(__weak_ptr<_Tp1, _Lp> 
const& __rhs) 
const noexcept
  1336         { 
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)
  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(
  1364               std::declval<
const __shared_count<_Lp>&>(),
  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   template<
typename _Tp, _Lock_policy _Lp>
  1421     operator==(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1424   template<
typename _Tp1, 
typename _Tp2, _Lock_policy _Lp>
  1426     operator!=(
const __shared_ptr<_Tp1, _Lp>& __a,
  1427                const __shared_ptr<_Tp2, _Lp>& __b) noexcept
  1428     { 
return __a.get() != __b.get(); }
  1430   template<
typename _Tp, _Lock_policy _Lp>
  1432     operator!=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
  1433     { 
return (
bool)__a; }
  1435   template<
typename _Tp, _Lock_policy _Lp>
  1437     operator!=(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1438     { 
return (
bool)__a; }
  1440   template<
typename _Tp, 
typename _Up, _Lock_policy _Lp>
  1442     operator<(
const __shared_ptr<_Tp, _Lp>& __a,
  1443               const __shared_ptr<_Up, _Lp>& __b) noexcept
  1445       using _Tp_elt = 
typename __shared_ptr<_Tp, _Lp>::element_type;
  1446       using _Up_elt = 
typename __shared_ptr<_Up, _Lp>::element_type;
  1447       using _Vp = 
typename common_type<_Tp_elt*, _Up_elt*>::type;
  1448       return less<_Vp>()(__a.get(), __b.get());
  1451   template<
typename _Tp, _Lock_policy _Lp>
  1453     operator<(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
  1455       using _Tp_elt = 
typename __shared_ptr<_Tp, _Lp>::element_type;
  1456       return less<_Tp_elt*>()(__a.get(), 
nullptr);
  1459   template<
typename _Tp, _Lock_policy _Lp>
  1461     operator<(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1463       using _Tp_elt = 
typename __shared_ptr<_Tp, _Lp>::element_type;
  1464       return less<_Tp_elt*>()(
nullptr, __a.get());
  1467   template<
typename _Tp1, 
typename _Tp2, _Lock_policy _Lp>
  1469     operator<=(
const __shared_ptr<_Tp1, _Lp>& __a,
  1470                const __shared_ptr<_Tp2, _Lp>& __b) noexcept
  1471     { 
return !(__b < __a); }
  1473   template<
typename _Tp, _Lock_policy _Lp>
  1475     operator<=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
  1476     { 
return !(
nullptr < __a); }
  1478   template<
typename _Tp, _Lock_policy _Lp>
  1480     operator<=(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1481     { 
return !(__a < 
nullptr); }
  1483   template<
typename _Tp1, 
typename _Tp2, _Lock_policy _Lp>
  1485     operator>(
const __shared_ptr<_Tp1, _Lp>& __a,
  1486               const __shared_ptr<_Tp2, _Lp>& __b) noexcept
  1487     { 
return (__b < __a); }
  1489   template<
typename _Tp, _Lock_policy _Lp>
  1491     operator>(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
  1492     { 
return nullptr < __a; }
  1494   template<
typename _Tp, _Lock_policy _Lp>
  1496     operator>(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1497     { 
return __a < 
nullptr; }
  1499   template<
typename _Tp1, 
typename _Tp2, _Lock_policy _Lp>
  1501     operator>=(
const __shared_ptr<_Tp1, _Lp>& __a,
  1502                const __shared_ptr<_Tp2, _Lp>& __b) noexcept
  1503     { 
return !(__a < __b); }
  1505   template<
typename _Tp, _Lock_policy _Lp>
  1507     operator>=(
const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
  1508     { 
return !(__a < 
nullptr); }
  1510   template<
typename _Tp, _Lock_policy _Lp>
  1512     operator>=(nullptr_t, 
const __shared_ptr<_Tp, _Lp>& __a) noexcept
  1513     { 
return !(
nullptr < __a); }
  1515   template<
typename _Sp>
  1516     struct _Sp_less : 
public binary_function<_Sp, _Sp, bool>
  1519       operator()(
const _Sp& __lhs, 
const _Sp& __rhs) 
const noexcept
  1521         typedef typename _Sp::element_type element_type;
  1526   template<
typename _Tp, _Lock_policy _Lp>
  1527     struct less<__shared_ptr<_Tp, _Lp>>
  1528     : 
public _Sp_less<__shared_ptr<_Tp, _Lp>>
  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>
  1546     static_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
  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>
  1559     const_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
  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>
  1572     dynamic_pointer_cast(
const __shared_ptr<_Tp1, _Lp>& __r) noexcept
  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
  1669         _M_ptr = __r._M_ptr;
  1670         _M_refcount = std::move(__r._M_refcount);
  1671         __r._M_ptr = 
nullptr;
  1675       template<
typename _Yp>
  1677         operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept
  1679           _M_ptr = __r.lock().get();
  1680           _M_refcount = std::move(__r._M_refcount);
  1681           __r._M_ptr = 
nullptr;
  1685       __shared_ptr<_Tp, _Lp>
  1686       lock() const noexcept
  1687       { 
return __shared_ptr<element_type, _Lp>(*
this, std::nothrow); }
  1690       use_count() const noexcept
  1691       { 
return _M_refcount._M_get_use_count(); }
  1694       expired() const noexcept
  1695       { 
return _M_refcount._M_get_use_count() == 0; }
  1697       template<
typename _Tp1>
  1699         owner_before(
const __shared_ptr<_Tp1, _Lp>& __rhs) 
const noexcept
  1700         { 
return _M_refcount._M_less(__rhs._M_refcount); }
  1702       template<
typename _Tp1>
  1704         owner_before(
const __weak_ptr<_Tp1, _Lp>& __rhs) 
const noexcept
  1705         { 
return _M_refcount._M_less(__rhs._M_refcount); }
  1709       { __weak_ptr().swap(*
this); }
  1712       swap(__weak_ptr& __s) noexcept
  1714         std::swap(_M_ptr, __s._M_ptr);
  1715         _M_refcount._M_swap(__s._M_refcount);
  1721       _M_assign(_Tp* __ptr, 
const __shared_count<_Lp>& __refcount) noexcept
  1723         if (use_count() == 0)
  1726             _M_refcount = __refcount;
  1730       template<
typename _Tp1, _Lock_policy _Lp1> 
friend class __shared_ptr;
  1731       template<
typename _Tp1, _Lock_policy _Lp1> 
friend class __weak_ptr;
  1732       friend class __enable_shared_from_this<_Tp, _Lp>;
  1733       friend class enable_shared_from_this<_Tp>;
  1735       element_type*      _M_ptr;         
  1736       __weak_count<_Lp>  _M_refcount;    
  1740   template<
typename _Tp, _Lock_policy _Lp>
  1742     swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
  1745   template<
typename _Tp, 
typename _Tp1>
  1746     struct _Sp_owner_less : 
public binary_function<_Tp, _Tp, bool>
  1749       operator()(
const _Tp& __lhs, 
const _Tp& __rhs) 
const noexcept
  1750       { 
return __lhs.owner_before(__rhs); }
  1753       operator()(
const _Tp& __lhs, 
const _Tp1& __rhs) 
const noexcept
  1754       { 
return __lhs.owner_before(__rhs); }
  1757       operator()(
const _Tp1& __lhs, 
const _Tp& __rhs) 
const noexcept
  1758       { 
return __lhs.owner_before(__rhs); }
  1762     struct _Sp_owner_less<void, void>
  1764       template<
typename _Tp, 
typename _Up>
  1766         operator()(
const _Tp& __lhs, 
const _Up& __rhs) 
const noexcept
  1767         -> decltype(__lhs.owner_before(__rhs))
  1768         { 
return __lhs.owner_before(__rhs); }
  1770       using is_transparent = void;
  1773   template<
typename _Tp, _Lock_policy _Lp>
  1774     struct owner_less<__shared_ptr<_Tp, _Lp>>
  1775     : 
public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>>
  1778   template<
typename _Tp, _Lock_policy _Lp>
  1779     struct owner_less<__weak_ptr<_Tp, _Lp>>
  1780     : 
public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>>
  1784   template<
typename _Tp, _Lock_policy _Lp>
  1785     class __enable_shared_from_this
  1788       constexpr __enable_shared_from_this() noexcept { }
  1790       __enable_shared_from_this(
const __enable_shared_from_this&) noexcept { }
  1792       __enable_shared_from_this&
  1793       operator=(
const __enable_shared_from_this&) noexcept
  1796       ~__enable_shared_from_this() { }
  1799       __shared_ptr<_Tp, _Lp>
  1801       { 
return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); }
  1803       __shared_ptr<const _Tp, _Lp>
  1804       shared_from_this()
 const  1805       { 
return __shared_ptr<const _Tp, _Lp>(this->_M_weak_this); }
  1807 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11  1808       __weak_ptr<_Tp, _Lp>
  1809       weak_from_this() noexcept
  1810       { 
return this->_M_weak_this; }
  1812       __weak_ptr<const _Tp, _Lp>
  1813       weak_from_this() const noexcept
  1814       { 
return this->_M_weak_this; }
  1818       template<
typename _Tp1>
  1820         _M_weak_assign(_Tp1* __p, 
const __shared_count<_Lp>& __n) 
const noexcept
  1821         { _M_weak_this._M_assign(__p, __n); }
  1823       friend const __enable_shared_from_this*
  1824       __enable_shared_from_this_base(
const __shared_count<_Lp>&,
  1825                                      const __enable_shared_from_this* __p)
  1828       template<
typename, _Lock_policy>
  1829         friend class __shared_ptr;
  1831       mutable __weak_ptr<_Tp, _Lp>  _M_weak_this;
  1834   template<
typename _Tp, _Lock_policy _Lp, 
typename _Alloc, 
typename... _Args>
  1835     inline __shared_ptr<_Tp, _Lp>
  1836     __allocate_shared(
const _Alloc& __a, _Args&&... __args)
  1838       return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a},
  1839                                     std::forward<_Args>(__args)...);
  1842   template<
typename _Tp, _Lock_policy _Lp, 
typename... _Args>
  1843     inline __shared_ptr<_Tp, _Lp>
  1844     __make_shared(_Args&&... __args)
  1846       typedef typename std::remove_const<_Tp>::type _Tp_nc;
  1848                                               std::forward<_Args>(__args)...);
  1852   template<
typename _Tp, _Lock_policy _Lp>
  1853     struct hash<__shared_ptr<_Tp, _Lp>>
  1854     : 
public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
  1857       operator()(
const __shared_ptr<_Tp, _Lp>& __s) 
const noexcept
  1864 _GLIBCXX_END_NAMESPACE_VERSION
  1867 #endif // _SHARED_PTR_BASE_H One of the comparison functors.
 
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
Generic lock.
 
20.7.1.2 unique_ptr for single objects.
 
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
 
A simple smart pointer providing strict ownership semantics.
 
The standard allocator, as per [20.4].
 
static void destroy(_Alloc &__a, _Tp *__p)
Destroy an object of type _Tp.
 
static auto construct(_Alloc &__a, _Tp *__p, _Args &&... __args) -> decltype(_S_construct(__a, __p, std::forward< _Args >(__args)...))
Construct an object of type _Tp.
 
Primary class template hash.
 
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
 
__allocated_ptr< _Alloc > __allocate_guarded(_Alloc &__a)
Allocate space for a single object using __a.
 
complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
 
ISO C++ entities toplevel namespace is std.
 
virtual char const  * what() const noexcept
 
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
 
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
 
Base class for all library exceptions.
 
Exception possibly thrown by shared_ptr.