14 namespace intrusive_ptr {
32 friend void Ref(
const T*);
34 friend void Unref(
const T*);
35 mutable uint64_t _references = 1;
39 inline void Ref(
const T* m) {
45 inline void Unref(
const T* m) {
46 if ( m && --m->_references == 0 )
76 using const_pointer =
const T*;
78 using element_type = T;
82 using const_reference =
const T&;
121 template<
class U,
class = std::enable_if_t<std::is_convertible_v<U*, T*>>>
131 void swap(
IntrusivePtr& other) noexcept { std::swap(ptr_, other.ptr_); }
135 swap(a.ptr_, b.ptr_);
153 #pragma GCC diagnostic push; 154 #pragma GCC diagnostic ignored "-Wpragmas" 155 #pragma GCC diagnostic ignored "-Wunknown-warning-option" 156 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 158 #pragma GCC diagnostic pop; 161 pointer operator->()
const noexcept {
return ptr_; }
163 reference operator*()
const noexcept {
return *ptr_; }
165 bool operator!()
const noexcept {
return ! ptr_; }
167 explicit operator bool()
const noexcept {
return ptr_ !=
nullptr; }
181 template<
class T,
class... Ts>
193 template<
class T,
class U>
221 return static_cast<bool>(x);
229 return static_cast<bool>(x);
274 template<
class T,
class U>
276 return x.get() == y.get();
282 template<
class T,
class U>
284 return x.get() != y.get();
IntrusivePtr(intrusive_ptr::NewRef, pointer raw_ptr) noexcept
Definition: intrusive-ptr.h:110
constexpr IntrusivePtr(intrusive_ptr::AdoptRef, pointer raw_ptr) noexcept
Definition: intrusive-ptr.h:100
Definition: intrusive-ptr.h:26
Definition: intrusive-ptr.h:20
Definition: intrusive-ptr.h:29
pointer release() noexcept
Definition: intrusive-ptr.h:143
IntrusivePtr< T > cast_intrusive(IntrusivePtr< U > p) noexcept
Definition: intrusive-ptr.h:194
IntrusivePtr< T > make_intrusive(Ts &&... args)
Definition: intrusive-ptr.h:182
Definition: intrusive-ptr.h:70