Go to the documentation of this file.
23 #ifndef STDEXT_SHARED_PTR_H
24 #define STDEXT_SHARED_PTR_H
28 #include <type_traits>
64 if(--weaks == 0 && refs == 0)
74 T *
get() {
return px; }
82 std::atomic<refcount_t> refs;
83 std::atomic<refcount_t> weaks;
102 shared_ptr(
shared_ptr<U> const& rhs,
typename std::is_convertible<U,T>::type* =
nullptr) : base(rhs.base) {
if(base !=
nullptr) base->add_ref(); }
109 void set(T* p) { assert(p !=
nullptr); base->set(p); }
110 T*
get()
const {
return base ? base->get() :
nullptr; }
116 T&
operator*()
const { assert(base !=
nullptr);
return *base->get(); }
117 T*
operator->()
const { assert(base !=
nullptr);
return base->get(); }
141 shared_base<T> *base;
163 T*
get()
const {
return base ? base->
get() :
nullptr; }
215 template<
class E,
class T,
class Y> std::basic_ostream<E, T>&
operator<<(std::basic_ostream<E, T>& os,
shared_ptr<Y> const& p) { os << p.get();
return os; }
216 template<
class E,
class T,
class Y> std::basic_ostream<E, T>&
operator<<(std::basic_ostream<E, T>& os,
weak_ptr<Y> const& p) { os << p.
get();
return os; }
shared_base< T > *weak_ptr::* unspecified_bool_type
void swap(stdext::packed_vector< T, U > &lhs, stdext::packed_vector< T, U > &rhs)
size_t operator()(const stdext::shared_ptr< T > &p) const
shared_ptr(shared_ptr &&rhs)
weak_ptr & operator=(weak_ptr &&rhs)
bool operator==(shared_object_ptr< T > const &a, shared_object_ptr< U > const &b)
shared_object_ptr< T > const_pointer_cast(shared_object_ptr< U > const &p)
void swap(shared_ptr &rhs)
bool operator!=(shared_object_ptr< T > const &a, shared_object_ptr< U > const &b)
shared_ptr & operator=(shared_ptr< U > const &rhs)
std::basic_ostream< E, T > & operator<<(std::basic_ostream< E, T > &os, shared_object_ptr< Y > const &p)
refcount_t weak_count() const
weak_ptr & operator=(weak_ptr const &rhs)
T * get_pointer(shared_object_ptr< T > const &p)
stdext::shared_ptr< T > make_shared(Args... args)
bool operator<(shared_object_ptr< T > const &a, shared_object_ptr< T > const &b)
weak_ptr(shared_ptr< U > const &rhs, typename std::is_convertible< U, T >::type *=nullptr)
weak_ptr & operator=(shared_ptr< U > const &rhs)
shared_base< T > *shared_ptr::* unspecified_bool_type
shared_ptr & operator=(T *rhs)
shared_ptr(shared_ptr const &rhs)
weak_ptr(shared_ptr< T > const &rhs)
refcount_t use_count() const
shared_ptr & operator=(shared_ptr &&rhs)
refcount_t weak_count() const
weak_ptr & operator=(weak_ptr< T > const &rhs)
shared_ptr(shared_ptr< U > const &rhs, typename std::is_convertible< U, T >::type *=nullptr)
weak_ptr(weak_ptr< U > const &rhs, typename std::is_convertible< U, T >::type *=nullptr)
weak_ptr(weak_ptr< T > const &rhs)
size_t operator()(const stdext::weak_ptr< T > &p) const
refcount_t use_count() const
shared_ptr & operator=(shared_ptr const &rhs)
shared_object_ptr< T > dynamic_pointer_cast(shared_object_ptr< U > const &p)
shared_object_ptr< T > static_pointer_cast(shared_object_ptr< U > const &p)