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()
103 shared_ptr(const shared_ptr&) = default; // never throws
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)
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)
222 * @brief Move-constructs a %shared_ptr instance from @a __r.
223 * @param __r A %shared_ptr rvalue.
226 shared_ptr(shared_ptr&& __r)
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)
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)
269 shared_ptr& operator=(const shared_ptr&) = default;
272 shared_ptr&
273 operator=(const shared_ptr<_Tp1>& __r) // never throws
281 shared_ptr&
289 shared_ptr&
290 operator=(shared_ptr&& __r)
297 shared_ptr&
298 operator=(shared_ptr<_Tp1>&& __r)
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, const shared_ptr<_Tp2>& __b)
333 operator==(const shared_ptr<_Tp>& __a, nullptr_t)
338 operator==(nullptr_t, const shared_ptr<_Tp>& __b)
343 operator!=(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b)
348 operator!=(const shared_ptr<_Tp>& __a, nullptr_t)
353 operator!=(nullptr_t, const shared_ptr<_Tp>& __b)
358 operator<(const shared_ptr<_Tp1>& __a, const shared_ptr<_Tp2>& __b)
362 struct less<shared_ptr<_Tp>> : public _Sp_less<shared_ptr<_Tp>>
365 // 20.8.13.2.9 shared_ptr specialized algorithms.
368 swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
371 // 20.8.13.2.10 shared_ptr casts.
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())); }
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())); }
383 inline shared_ptr<_Tp>
384 dynamic_pointer_cast(const shared_ptr<_Tp1>& __r)
387 return shared_ptr<_Tp>(__r, __p);
388 return shared_ptr<_Tp>();
411 weak_ptr(const shared_ptr<_Tp1>& __r)
424 operator=(const shared_ptr<_Tp1>& __r) // never throws
430 shared_ptr<_Tp>
435 return shared_ptr<_Tp>();
439 return shared_ptr<_Tp>(*this);
443 return shared_ptr<_Tp>();
446 return this->expired() ? shared_ptr<_Tp>() : shared_ptr<_Tp>(*this);
462 /// Partial specialization of owner_less for shared_ptr.
464 struct owner_less<shared_ptr<_Tp>>
465 : public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
471 : public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
492 shared_ptr<_Tp>
494 { return shared_ptr<_Tp>(this->_M_weak_this); }
496 shared_ptr<const _Tp>
498 { return shared_ptr<const _Tp>(this->_M_weak_this); }
520 * @brief Create an object that is owned by a shared_ptr.
523 * @return A shared_ptr that owns the newly created object.
527 * A copy of @a __a will be used to allocate memory for the shared_ptr
531 inline shared_ptr<_Tp>
534 return shared_ptr<_Tp>(_Sp_make_shared_tag(), __a,
539 * @brief Create an object that is owned by a shared_ptr.
541 * @return A shared_ptr that owns the newly created object.
546 inline shared_ptr<_Tp>
554 /// std::hash specialization for shared_ptr.
556 struct hash<shared_ptr<_Tp>>
557 : public std::unary_function<shared_ptr<_Tp>, size_t>
560 operator()(const shared_ptr<_Tp>& __s) const noexcept