Home | History | Annotate | Download | only in bits

Lines Matching refs:shared_ptr

0 // shared_ptr and weak_ptr implementation -*- C++ -*-
30 // shared_ptr.hpp
44 /** @file bits/shared_ptr.h
63 /// 20.7.2.2.11 shared_ptr I/O
73 /// 20.7.2.2.10 shared_ptr get_deleter
89 * The object pointed to is deleted when the last shared_ptr pointing to
93 class shared_ptr : public __shared_ptr<_Tp>
97 * @brief Construct an empty %shared_ptr.
100 constexpr shared_ptr() noexcept
103 shared_ptr(const shared_ptr&) noexcept = default;
106 * @brief Construct a %shared_ptr that owns the pointer @a __p.
112 explicit shared_ptr(_Tp1* __p)
116 * @brief Construct a %shared_ptr that owns the pointer @a __p
129 shared_ptr(_Tp1* __p, _Deleter __d)
133 * @brief Construct a %shared_ptr that owns a null pointer
146 shared_ptr(nullptr_t __p, _Deleter __d)
150 * @brief Construct a %shared_ptr that owns the pointer @a __p
165 shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
169 * @brief Construct a %shared_ptr that owns a null pointer
184 shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
190 * @brief Constructs a %shared_ptr instance that stores @a __p
192 * @param __r A %shared_ptr.
196 * This can be used to construct a @c shared_ptr to a sub-object
197 * of an object managed by an existing @c shared_ptr.
200 * shared_ptr< pair<int,int> > pii(new pair<int,int>());
201 * shared_ptr<int> pi(pii, &pii->first);
206 shared_ptr(const shared_ptr<_Tp1>& __r, _Tp* __p) noexcept
210 * @brief If @a __r is empty, constructs an empty %shared_ptr;
211 * otherwise construct a %shared_ptr that shares ownership
213 * @param __r A %shared_ptr.
218 shared_ptr(const shared_ptr<_Tp1>& __r) noexcept
222 * @brief Move-constructs a %shared_ptr instance from @a __r.
223 * @param __r A %shared_ptr rvalue.
226 shared_ptr(shared_ptr&& __r) noexcept
230 * @brief Move-constructs a %shared_ptr instance from @a __r.
231 * @param __r A %shared_ptr rvalue.
236 shared_ptr(shared_ptr<_Tp1>&& __r) noexcept
240 * @brief Constructs a %shared_ptr that shares ownership with @a __r
248 explicit shared_ptr(const weak_ptr<_Tp1>& __r)
253 shared_ptr(std::auto_ptr<_Tp1>&& __r);
257 shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
261 * @brief Construct an empty %shared_ptr.
265 constexpr shared_ptr(nullptr_t __p) noexcept
268 shared_ptr& operator=(const shared_ptr&) noexcept = default;
271 shared_ptr&
272 operator=(const shared_ptr<_Tp1>& __r) noexcept
280 shared_ptr&
288 shared_ptr&
289 operator=(shared_ptr&& __r) noexcept
296 shared_ptr&
297 operator=(shared_ptr<_Tp1>&& __r) noexcept
304 shared_ptr&
314 shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
320 friend shared_ptr<_Tp1>
324 shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t)
330 // 20.7.2.2.7 shared_ptr comparisons
333 operator==(const shared_ptr<_Tp1>& __a,
334 const shared_ptr<_Tp2>& __b) noexcept
339 operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
344 operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
349 operator!=(const shared_ptr<_Tp1>& __a,
350 const shared_ptr<_Tp2>& __b) noexcept
355 operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
360 operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
365 operator<(const shared_ptr<_Tp1>& __a,
366 const shared_ptr<_Tp2>& __b) noexcept
374 operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
379 operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
384 operator<=(const shared_ptr<_Tp1>& __a,
385 const shared_ptr<_Tp2>& __b) noexcept
390 operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
395 operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
400 operator>(const shared_ptr<_Tp1>& __a,
401 const shared_ptr<_Tp2>& __b) noexcept
406 operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
411 operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
416 operator>=(const shared_ptr<_Tp1>& __a,
417 const shared_ptr<_Tp2>& __b) noexcept
422 operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
427 operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
431 struct less<shared_ptr<_Tp>> : public _Sp_less<shared_ptr<_Tp>>
434 // 20.7.2.2.8 shared_ptr specialized algorithms.
437 swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
440 // 20.7.2.2.9 shared_ptr casts.
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())); }
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())); }
452 inline shared_ptr<_Tp>
453 dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
456 return shared_ptr<_Tp>(__r, __p);
457 return shared_ptr<_Tp>();
480 weak_ptr(const shared_ptr<_Tp1>& __r) noexcept
493 operator=(const shared_ptr<_Tp1>& __r) noexcept
499 shared_ptr<_Tp>
501 { return shared_ptr<_Tp>(*this, std::nothrow); }
515 /// Partial specialization of owner_less for shared_ptr.
517 struct owner_less<shared_ptr<_Tp>>
518 : public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
524 : public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
545 shared_ptr<_Tp>
547 { return shared_ptr<_Tp>(this->_M_weak_this); }
549 shared_ptr<const _Tp>
551 { return shared_ptr<const _Tp>(this->_M_weak_this); }
573 * @brief Create an object that is owned by a shared_ptr.
576 * @return A shared_ptr that owns the newly created object.
580 * A copy of @a __a will be used to allocate memory for the shared_ptr
584 inline shared_ptr<_Tp>
587 return shared_ptr<_Tp>(_Sp_make_shared_tag(), __a,
592 * @brief Create an object that is owned by a shared_ptr.
594 * @return A shared_ptr that owns the newly created object.
599 inline shared_ptr<_Tp>
607 /// std::hash specialization for shared_ptr.
609 struct hash<shared_ptr<_Tp>>
610 : public __hash_base<size_t, shared_ptr<_Tp>>
613 operator()(const shared_ptr<_Tp>& __s) const noexcept