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>
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
219 : __shared_ptr<_Tp>(__r) { }
227 : __shared_ptr<_Tp>(std::move(__r)) { }
234 template<
typename _Tp1,
typename =
typename
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>
254 : __shared_ptr<_Tp>(std::move(__r)) { }
257 template<
typename _Tp1,
typename _Del>
259 : __shared_ptr<_Tp>(std::move(__r)) { }
267 : __shared_ptr<_Tp>(__p) { }
271 template<
typename _Tp1>
275 this->__shared_ptr<_Tp>::operator=(__r);
279 #if _GLIBCXX_USE_DEPRECATED
280 template<
typename _Tp1>
284 this->__shared_ptr<_Tp>::operator=(std::move(__r));
292 this->__shared_ptr<_Tp>::operator=(std::move(__r));
298 operator=(shared_ptr<_Tp1>&& __r)
300 this->__shared_ptr<_Tp>::operator=(std::move(__r));
304 template<
typename _Tp1,
typename _Del>
308 this->__shared_ptr<_Tp>::operator=(std::move(__r));
314 template<
typename _Alloc,
typename... _Args>
315 shared_ptr(_Sp_make_shared_tag __tag,
const _Alloc& __a,
317 : __shared_ptr<_Tp>(__tag, __a, std::
forward<_Args>(__args)...)
320 template<
typename _Tp1,
typename _Alloc,
typename... _Args>
321 friend shared_ptr<_Tp1>
326 template<
typename _Tp1,
typename _Tp2>
328 operator==(
const shared_ptr<_Tp1>& __a,
const shared_ptr<_Tp2>& __b)
329 {
return __a.get() == __b.get(); }
331 template<
typename _Tp>
333 operator==(
const shared_ptr<_Tp>& __a, nullptr_t)
334 {
return __a.get() ==
nullptr; }
336 template<
typename _Tp>
338 operator==(nullptr_t,
const shared_ptr<_Tp>& __b)
339 {
return nullptr == __b.get(); }
341 template<
typename _Tp1,
typename _Tp2>
343 operator!=(
const shared_ptr<_Tp1>& __a,
const shared_ptr<_Tp2>& __b)
344 {
return __a.get() != __b.get(); }
346 template<
typename _Tp>
348 operator!=(
const shared_ptr<_Tp>& __a, nullptr_t)
349 {
return __a.get() !=
nullptr; }
351 template<
typename _Tp>
353 operator!=(nullptr_t,
const shared_ptr<_Tp>& __b)
354 {
return nullptr != __b.get(); }
356 template<
typename _Tp1,
typename _Tp2>
358 operator<(const shared_ptr<_Tp1>& __a,
const shared_ptr<_Tp2>& __b)
359 {
return __a.get() < __b.get(); }
361 template<
typename _Tp>
362 struct less<shared_ptr<_Tp>> :
public _Sp_less<shared_ptr<_Tp>>
366 template<
typename _Tp>
368 swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
372 template<
typename _Tp,
typename _Tp1>
373 inline shared_ptr<_Tp>
374 static_pointer_cast(
const shared_ptr<_Tp1>& __r)
375 {
return shared_ptr<_Tp>(__r,
static_cast<_Tp*
>(__r.get())); }
377 template<
typename _Tp,
typename _Tp1>
378 inline shared_ptr<_Tp>
379 const_pointer_cast(
const shared_ptr<_Tp1>& __r)
380 {
return shared_ptr<_Tp>(__r,
const_cast<_Tp*
>(__r.get())); }
382 template<
typename _Tp,
typename _Tp1>
383 inline shared_ptr<_Tp>
384 dynamic_pointer_cast(
const shared_ptr<_Tp1>& __r)
386 if (_Tp* __p = dynamic_cast<_Tp*>(__r.get()))
387 return shared_ptr<_Tp>(__r, __p);
388 return shared_ptr<_Tp>();
397 template<
typename _Tp>
402 : __weak_ptr<_Tp>() { }
404 template<
typename _Tp1,
typename =
typename
407 : __weak_ptr<_Tp>(__r) { }
409 template<
typename _Tp1,
typename =
typename
412 : __weak_ptr<_Tp>(__r) { }
414 template<
typename _Tp1>
418 this->__weak_ptr<_Tp>::operator=(__r);
422 template<
typename _Tp1>
426 this->__weak_ptr<_Tp>::operator=(__r);
452 template<
typename _Tp>
459 template<
typename _Tp>
463 template<
typename _Tp>
465 :
public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
469 template<
typename _Tp>
471 :
public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
477 template<
typename _Tp>
497 shared_from_this()
const
501 template<
typename _Tp1>
503 _M_weak_assign(_Tp1* __p,
const __shared_count<>& __n)
const
504 { _M_weak_this._M_assign(__p, __n); }
506 template<
typename _Tp1>
508 __enable_shared_from_this_helper(
const __shared_count<>& __pn,
513 __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
530 template<
typename _Tp,
typename _Alloc,
typename... _Args>
535 std::forward<_Args>(__args)...);
545 template<
typename _Tp,
typename... _Args>
546 inline shared_ptr<_Tp>
549 typedef typename std::remove_const<_Tp>::type _Tp_nc;
551 std::forward<_Args>(__args)...);
555 template<
typename _Tp>
566 _GLIBCXX_END_NAMESPACE_VERSION
569 #endif // _SHARED_PTR_H
shared_ptr(nullptr_t __p, _Deleter __d)
Construct a shared_ptr that owns a null pointer and the deleter __d.
constexpr shared_ptr(nullptr_t __p)
Construct an empty shared_ptr.
A simple smart pointer providing strict ownership semantics.
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
20.7.12.2 unique_ptr for single objects.
Exception possibly thrown by shared_ptr.
shared_ptr< _Tp > make_shared(_Args &&...__args)
Create an object that is owned by a shared_ptr.
shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
Construct a shared_ptr that owns a null pointer and the deleter __d.
shared_ptr(_Tp1 *__p, _Deleter __d, _Alloc __a)
Construct a shared_ptr that owns the pointer __p and the deleter __d.
_Del * get_deleter(const __shared_ptr< _Tp, _Lp > &__p)
2.2.3.10 shared_ptr get_deleter (experimental)
shared_ptr(const shared_ptr< _Tp1 > &__r)
If __r is empty, constructs an empty shared_ptr; otherwise construct a shared_ptr that shares ownersh...
shared_ptr< _Tp > allocate_shared(const _Alloc &__a, _Args &&...__args)
Create an object that is owned by a shared_ptr.
Partial specializations for pointer types.
A smart pointer with reference-counted copy semantics.
Primary class template hash.
shared_ptr(const shared_ptr< _Tp1 > &__r, _Tp *__p)
Constructs a shared_ptr instance that stores __p and shares ownership with __r.
Primary template owner_less.
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...
constexpr shared_ptr()
Construct an empty shared_ptr.
friend shared_ptr< _Tp1 > allocate_shared(const _Alloc &__a, _Args &&...__args)
Create an object that is owned by a shared_ptr.
A smart pointer with weak semantics.
Base class allowing use of member function shared_from_this.
shared_ptr(shared_ptr< _Tp1 > &&__r)
Move-constructs a shared_ptr instance from __r.
shared_ptr(_Tp1 *__p)
Construct a shared_ptr that owns the pointer __p.
shared_ptr(_Tp1 *__p, _Deleter __d)
Construct a shared_ptr that owns the pointer __p and the deleter __d.
shared_ptr(shared_ptr &&__r)
Move-constructs a shared_ptr instance from __r.
_Tp && forward(typename std::remove_reference< _Tp >::type &__t)
forward (as per N3143)
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...