50 #define _SHARED_PTR_H 1 
   54 namespace std _GLIBCXX_VISIBILITY(default)
 
   56 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   64   template<
typename _Ch, 
typename _Tr, 
typename _Tp, _Lock_policy _Lp>
 
   65     inline std::basic_ostream<_Ch, _Tr>&
 
   66     operator<<(std::basic_ostream<_Ch, _Tr>& __os,
 
   67            const __shared_ptr<_Tp, _Lp>& __p)
 
   74   template<
typename _Del, 
typename _Tp, _Lock_policy _Lp>
 
   79       return static_cast<_Del*
>(__p._M_get_deleter(
typeid(_Del)));
 
   92   template<
typename _Tp>
 
  101       : __shared_ptr<_Tp>() { }
 
  111       template<typename _Tp1>
 
  113         : __shared_ptr<_Tp>(__p) { }
 
  128       template<
typename _Tp1, 
typename _Deleter>
 
  130         : __shared_ptr<_Tp>(__p, __d) { }
 
  145       template<
typename _Deleter>
 
  147         : __shared_ptr<_Tp>(__p, __d) { }
 
  164       template<
typename _Tp1, 
typename _Deleter, 
typename _Alloc>
 
  166     : __shared_ptr<_Tp>(__p, __d, 
std::
move(__a)) { }
 
  183       template<
typename _Deleter, 
typename _Alloc>
 
  185     : __shared_ptr<_Tp>(__p, __d, 
std::
move(__a)) { }
 
  205       template<
typename _Tp1>
 
  207     : __shared_ptr<_Tp>(__r, __p) { }
 
  216       template<
typename _Tp1, 
typename = 
typename 
  217            std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
 
  219         : __shared_ptr<_Tp>(__r) { }
 
  227       : __shared_ptr<_Tp>(
std::
move(__r)) { }
 
  234       template<
typename _Tp1, 
typename = 
typename 
  235            std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
 
  237     : __shared_ptr<_Tp>(
std::
move(__r)) { }
 
  247       template<
typename _Tp1>
 
  249     : __shared_ptr<_Tp>(__r) { }
 
  251 #if _GLIBCXX_USE_DEPRECATED 
  252       template<
typename _Tp1>
 
  256       template<
typename _Tp1, 
typename _Del>
 
  258     : __shared_ptr<_Tp>(
std::
move(__r)) { }
 
  266       : __shared_ptr<_Tp>(__p) { }
 
  270       template<typename _Tp1>
 
  272     operator=(const 
shared_ptr<_Tp1>& __r) noexcept
 
  274       this->__shared_ptr<_Tp>::operator=(__r);
 
  278 #if _GLIBCXX_USE_DEPRECATED 
  279       template<
typename _Tp1>
 
  283       this->__shared_ptr<_Tp>::operator=(
std::move(__r));
 
  291     this->__shared_ptr<_Tp>::operator=(
std::move(__r));
 
  297     operator=(shared_ptr<_Tp1>&& __r) noexcept
 
  299       this->__shared_ptr<_Tp>::operator=(
std::move(__r));
 
  303       template<
typename _Tp1, 
typename _Del>
 
  307       this->__shared_ptr<_Tp>::operator=(
std::move(__r));
 
  313       template<
typename _Alloc, 
typename... _Args>
 
  314     shared_ptr(_Sp_make_shared_tag __tag, 
const _Alloc& __a,
 
  316     : __shared_ptr<_Tp>(__tag, __a, 
std::
forward<_Args>(__args)...)
 
  319       template<
typename _Tp1, 
typename _Alloc, 
typename... _Args>
 
  320     friend shared_ptr<_Tp1>
 
  324       shared_ptr(
const weak_ptr<_Tp>& __r, std::nothrow_t)
 
  325       : __shared_ptr<_Tp>(__r, 
std::nothrow) { }
 
  327       friend class weak_ptr<_Tp>;
 
  331   template<
typename _Tp1, 
typename _Tp2>
 
  333     operator==(
const shared_ptr<_Tp1>& __a,
 
  334            const shared_ptr<_Tp2>& __b) noexcept
 
  335     { 
return __a.get() == __b.get(); }
 
  337   template<
typename _Tp>
 
  339     operator==(
const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  342   template<
typename _Tp>
 
  344     operator==(nullptr_t, 
const shared_ptr<_Tp>& __a) noexcept
 
  347   template<
typename _Tp1, 
typename _Tp2>
 
  349     operator!=(
const shared_ptr<_Tp1>& __a,
 
  350            const shared_ptr<_Tp2>& __b) noexcept
 
  351     { 
return __a.get() != __b.get(); }
 
  353   template<
typename _Tp>
 
  355     operator!=(
const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  356     { 
return (
bool)__a; }
 
  358   template<
typename _Tp>
 
  360     operator!=(nullptr_t, 
const shared_ptr<_Tp>& __a) noexcept
 
  361     { 
return (
bool)__a; }
 
  363   template<
typename _Tp1, 
typename _Tp2>
 
  365     operator<(const shared_ptr<_Tp1>& __a,
 
  366           const shared_ptr<_Tp2>& __b) noexcept
 
  368       typedef typename std::common_type<_Tp1*, _Tp2*>::type _CT;
 
  372   template<
typename _Tp>
 
  374     operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  377   template<
typename _Tp>
 
  379     operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
 
  382   template<
typename _Tp1, 
typename _Tp2>
 
  384     operator<=(const shared_ptr<_Tp1>& __a,
 
  385            const shared_ptr<_Tp2>& __b) noexcept
 
  386     { 
return !(__b < __a); }
 
  388   template<
typename _Tp>
 
  390     operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  391     { 
return !(
nullptr < __a); }
 
  393   template<
typename _Tp>
 
  395     operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
 
  396     { 
return !(__a < 
nullptr); }
 
  398   template<
typename _Tp1, 
typename _Tp2>
 
  401           const shared_ptr<_Tp2>& __b) noexcept
 
  402     { 
return (__b < __a); }
 
  404   template<
typename _Tp>
 
  406     operator>(
const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  409   template<
typename _Tp>
 
  411     operator>(nullptr_t, 
const shared_ptr<_Tp>& __a) noexcept
 
  414   template<
typename _Tp1, 
typename _Tp2>
 
  417            const shared_ptr<_Tp2>& __b) noexcept
 
  418     { 
return !(__a < __b); }
 
  420   template<
typename _Tp>
 
  422     operator>=(
const shared_ptr<_Tp>& __a, nullptr_t) noexcept
 
  423     { 
return !(__a < 
nullptr); }
 
  425   template<
typename _Tp>
 
  427     operator>=(nullptr_t, 
const shared_ptr<_Tp>& __a) noexcept
 
  428     { 
return !(
nullptr < __a); }
 
  430   template<
typename _Tp>
 
  431     struct less<shared_ptr<_Tp>> : 
public _Sp_less<shared_ptr<_Tp>>
 
  435   template<
typename _Tp>
 
  437     swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
 
  441   template<
typename _Tp, 
typename _Tp1>
 
  442     inline shared_ptr<_Tp>
 
  443     static_pointer_cast(
const shared_ptr<_Tp1>& __r) noexcept
 
  444     { 
return shared_ptr<_Tp>(__r, 
static_cast<_Tp*
>(__r.get())); }
 
  446   template<
typename _Tp, 
typename _Tp1>
 
  447     inline shared_ptr<_Tp>
 
  448     const_pointer_cast(
const shared_ptr<_Tp1>& __r) noexcept
 
  449     { 
return shared_ptr<_Tp>(__r, 
const_cast<_Tp*
>(__r.get())); }
 
  451   template<
typename _Tp, 
typename _Tp1>
 
  452     inline shared_ptr<_Tp>
 
  453     dynamic_pointer_cast(
const shared_ptr<_Tp1>& __r) noexcept
 
  455       if (_Tp* __p = dynamic_cast<_Tp*>(__r.get()))
 
  456     return shared_ptr<_Tp>(__r, __p);
 
  457       return shared_ptr<_Tp>();
 
  466   template<
typename _Tp>
 
  471       : __weak_ptr<_Tp>() { }
 
  473       template<
typename _Tp1, 
typename = 
typename 
  474            std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
 
  476     : __weak_ptr<_Tp>(__r) { }
 
  478       template<
typename _Tp1, 
typename = 
typename 
  479            std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
 
  481     : __weak_ptr<_Tp>(__r) { }
 
  483       template<
typename _Tp1>
 
  487       this->__weak_ptr<_Tp>::operator=(__r);
 
  491       template<
typename _Tp1>
 
  495       this->__weak_ptr<_Tp>::operator=(__r);
 
  500       lock() 
const noexcept
 
  505   template<
typename _Tp>
 
  512   template<
typename _Tp>
 
  516   template<
typename _Tp>
 
  518     : 
public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
 
  522   template<
typename _Tp>
 
  524     : 
public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
 
  530   template<
typename _Tp>
 
  550       shared_from_this()
 const 
  554       template<
typename _Tp1>
 
  556     _M_weak_assign(_Tp1* __p, 
const __shared_count<>& __n) 
const noexcept
 
  557     { _M_weak_this._M_assign(__p, __n); }
 
  559       template<
typename _Tp1>
 
  561     __enable_shared_from_this_helper(
const __shared_count<>& __pn,
 
  563                      const _Tp1* __px) noexcept
 
  566         __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
 
  583   template<
typename _Tp, 
typename _Alloc, 
typename... _Args>
 
  588                  std::forward<_Args>(__args)...);
 
  598   template<
typename _Tp, 
typename... _Args>
 
  599     inline shared_ptr<_Tp>
 
  602       typedef typename std::remove_const<_Tp>::type _Tp_nc;
 
  604                        std::forward<_Args>(__args)...);
 
  608   template<
typename _Tp>
 
  610     : 
public __hash_base<size_t, shared_ptr<_Tp>>
 
  619 _GLIBCXX_END_NAMESPACE_VERSION
 
  622 #endif // _SHARED_PTR_H 
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue. 
Partial specializations for pointer types. 
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue. 
shared_ptr(const weak_ptr< _Tp1 > &__r)
Constructs a shared_ptr that shares ownership with __r and stores a copy of the pointer stored in __r...
A simple smart pointer providing strict ownership semantics. 
shared_ptr(const shared_ptr< _Tp1 > &__r) noexcept
If __r is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownersh...
A smart pointer with reference-counted copy semantics. 
shared_ptr(shared_ptr &&__r) noexcept
Move-constructs a shared_ptr instance from __r. 
shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
Construct a shared_ptr that owns a null pointer and the deleter __d. 
ISO C++ entities toplevel namespace is std. 
shared_ptr< _Tp > allocate_shared(const _Alloc &__a, _Args &&...__args)
Create an object that is owned by a shared_ptr. 
shared_ptr(const shared_ptr< _Tp1 > &__r, _Tp *__p) noexcept
Constructs a shared_ptr instance that stores __p and shares ownership with __r. 
friend shared_ptr< _Tp1 > allocate_shared(const _Alloc &__a, _Args &&...__args)
Create an object that is owned by a shared_ptr. 
The standard allocator, as per [20.4]. 
Primary template owner_less. 
shared_ptr(_Tp1 *__p, _Deleter __d)
Construct a shared_ptr that owns the pointer __p and the deleter __d. 
shared_ptr< _Tp > make_shared(_Args &&...__args)
Create an object that is owned by a shared_ptr. 
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string. 
shared_ptr(_Tp1 *__p, _Deleter __d, _Alloc __a)
Construct a shared_ptr that owns the pointer __p and the deleter __d. 
Base class allowing use of member function shared_from_this. 
Primary class template hash. 
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string. 
constexpr shared_ptr() noexcept
Construct an empty shared_ptr. 
A smart pointer with weak semantics. 
shared_ptr(shared_ptr< _Tp1 > &&__r) noexcept
Move-constructs a shared_ptr instance from __r. 
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values. 
shared_ptr(nullptr_t __p, _Deleter __d)
Construct a shared_ptr that owns a null pointer and the deleter __d. 
One of the comparison functors. 
_Del * get_deleter(const __shared_ptr< _Tp, _Lp > &__p) noexcept
20.7.2.2.10 shared_ptr get_deleter 
20.7.1.2 unique_ptr for single objects. 
constexpr shared_ptr(nullptr_t __p) noexcept
Construct an empty shared_ptr.