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 /// 2.2.3.7 shared_ptr I/O
73 /// 2.2.3.10 shared_ptr get_deleter (experimental)
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)
258 shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
262 * @brief Construct an empty %shared_ptr.
266 constexpr shared_ptr(nullptr_t __p) noexcept
269 shared_ptr& operator=(const shared_ptr&) noexcept = default;
272 shared_ptr&
273 operator=(const shared_ptr<_Tp1>& __r) noexcept
281 shared_ptr&
289 shared_ptr&
290 operator=(shared_ptr&& __r) noexcept
297 shared_ptr&
298 operator=(shared_ptr<_Tp1>&& __r) noexcept
305 shared_ptr&
315 shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
321 friend shared_ptr<_Tp1>
325 // 20.8.13.2.7 shared_ptr comparisons
328 operator==(const shared_ptr<_Tp1>& __a,
329 const shared_ptr<_Tp2>& __b) noexcept
334 operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
339 operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
344 operator!=(const shared_ptr<_Tp1>& __a,
345 const shared_ptr<_Tp2>& __b) noexcept
350 operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
355 operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
360 operator<(const shared_ptr<_Tp1>& __a,
361 const shared_ptr<_Tp2>& __b) noexcept
369 operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
374 operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
379 operator<=(const shared_ptr<_Tp1>& __a,
380 const shared_ptr<_Tp2>& __b) noexcept
385 operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
390 operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
395 operator>(const shared_ptr<_Tp1>& __a,
396 const shared_ptr<_Tp2>& __b) noexcept
401 operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
406 operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
411 operator>=(const shared_ptr<_Tp1>& __a,
412 const shared_ptr<_Tp2>& __b) noexcept
417 operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
422 operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
426 struct less<shared_ptr<_Tp>> : public _Sp_less<shared_ptr<_Tp>>
429 // 20.8.13.2.9 shared_ptr specialized algorithms.
432 swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
435 // 20.8.13.2.10 shared_ptr casts.
437 inline shared_ptr<_Tp>
438 static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
439 { return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); }
442 inline shared_ptr<_Tp>
443 const_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
444 { return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); }
447 inline shared_ptr<_Tp>
448 dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
451 return shared_ptr<_Tp>(__r, __p);
452 return shared_ptr<_Tp>();
475 weak_ptr(const shared_ptr<_Tp1>& __r) noexcept
488 operator=(const shared_ptr<_Tp1>& __r) noexcept
494 shared_ptr<_Tp>
499 return shared_ptr<_Tp>();
503 return shared_ptr<_Tp>(*this);
507 return shared_ptr<_Tp>();
510 return this->expired() ? shared_ptr<_Tp>() : shared_ptr<_Tp>(*this);
526 /// Partial specialization of owner_less for shared_ptr.
528 struct owner_less<shared_ptr<_Tp>>
529 shared_ptr<_Tp>, weak_ptr<_Tp>>
535 : public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
556 shared_ptr<_Tp>
558 { return shared_ptr<_Tp>(this->_M_weak_this); }
560 shared_ptr<const _Tp>
562 { return shared_ptr<const _Tp>(this->_M_weak_this); }
584 * @brief Create an object that is owned by a shared_ptr.
587 * @return A shared_ptr that owns the newly created object.
591 * A copy of @a __a will be used to allocate memory for the shared_ptr
595 inline shared_ptr<_Tp>
598 return shared_ptr<_Tp>(_Sp_make_shared_tag(), __a,
603 * @brief Create an object that is owned by a shared_ptr.
605 * @return A shared_ptr that owns the newly created object.
610 inline shared_ptr<_Tp>
618 /// std::hash specialization for shared_ptr.
620 struct hash<shared_ptr<_Tp>>
621 : public __hash_base<size_t, shared_ptr<_Tp>>
624 operator()(const shared_ptr<_Tp>& __s) const noexcept