13 namespace intrusive_ptr {
31 friend void Ref(
const T*);
33 friend void Unref(
const T*);
34 mutable uint64_t _references = 1;
38 inline void Ref(
const T* m) {
44 inline void Unref(
const T* m) {
45 if ( m && --m->_references == 0 )
75 using const_pointer =
const T*;
77 using element_type = T;
81 using const_reference =
const T&;
120 template<
class U,
class = std::enable_if_t<std::is_convertible_v<U*, T*>>>
130 void swap(
IntrusivePtr& other) noexcept { std::swap(ptr_, other.ptr_); }
134 swap(a.ptr_, b.ptr_);
149 pointer get()
const noexcept {
return ptr_; }
151 pointer operator->()
const noexcept {
return ptr_; }
153 reference operator*()
const noexcept {
return *ptr_; }
155 bool operator!()
const noexcept {
return ! ptr_; }
157 explicit operator bool()
const noexcept {
return ptr_ !=
nullptr; }
171 template<
class T,
class... Ts>
183 template<
class T,
class U>
211 return static_cast<bool>(x);
219 return static_cast<bool>(x);
264 template<
class T,
class U>
266 return x.get() == y.get();
272 template<
class T,
class U>
274 return x.get() != y.get();
IntrusivePtr(intrusive_ptr::NewRef, pointer raw_ptr) noexcept
Definition: intrusive-ptr.h:109
constexpr IntrusivePtr(intrusive_ptr::AdoptRef, pointer raw_ptr) noexcept
Definition: intrusive-ptr.h:99
Definition: intrusive-ptr.h:25
Definition: intrusive-ptr.h:19
Definition: intrusive-ptr.h:28
pointer release() noexcept
Definition: intrusive-ptr.h:142
IntrusivePtr< T > cast_intrusive(IntrusivePtr< U > p) noexcept
Definition: intrusive-ptr.h:184
IntrusivePtr< T > make_intrusive(Ts &&... args)
Definition: intrusive-ptr.h:172
Definition: intrusive-ptr.h:69