Flutter Engine
 
Loading...
Searching...
No Matches
fml::RefPtr< T > Class Template Referencefinal

#include <ref_ptr.h>

Public Member Functions

 RefPtr ()
 
 RefPtr (std::nullptr_t)
 
template<typename U >
 RefPtr (U *p)
 
 RefPtr (const RefPtr< T > &r)
 
template<typename U >
 RefPtr (const RefPtr< U > &r)
 
 RefPtr (RefPtr< T > &&r)
 
template<typename U >
 RefPtr (RefPtr< U > &&r)
 
 ~RefPtr ()
 
T * get () const
 
T & operator* () const
 
T * operator-> () const
 
RefPtr< T > & operator= (const RefPtr< T > &r)
 
template<typename U >
RefPtr< T > & operator= (const RefPtr< U > &r)
 
RefPtr< T > & operator= (RefPtr< T > &&r)
 
template<typename U >
RefPtr< T > & operator= (RefPtr< U > &&r)
 
void swap (RefPtr< T > &r)
 
RefPtr< T > Clone () const
 
 operator bool () const
 
template<typename U >
bool operator== (const RefPtr< U > &rhs) const
 
template<typename U >
bool operator!= (const RefPtr< U > &rhs) const
 
template<typename U >
bool operator< (const RefPtr< U > &rhs) const
 

Friends

template<typename U >
class RefPtr
 
RefPtr< T > AdoptRef (T *)
 

Detailed Description

template<typename T>
class fml::RefPtr< T >

Definition at line 65 of file ref_ptr.h.

Constructor & Destructor Documentation

◆ RefPtr() [1/7]

template<typename T >
fml::RefPtr< T >::RefPtr ( )
inline

Definition at line 67 of file ref_ptr.h.

67: ptr_(nullptr) {}

◆ RefPtr() [2/7]

template<typename T >
fml::RefPtr< T >::RefPtr ( std::nullptr_t  )
inline

Definition at line 68 of file ref_ptr.h.

69 : ptr_(nullptr) {}

◆ RefPtr() [3/7]

template<typename T >
template<typename U >
fml::RefPtr< T >::RefPtr ( U *  p)
inlineexplicit

Definition at line 76 of file ref_ptr.h.

76 : ptr_(p) {
77 if (ptr_) {
78 ptr_->AddRef();
79 }
80 }

◆ RefPtr() [4/7]

template<typename T >
fml::RefPtr< T >::RefPtr ( const RefPtr< T > &  r)
inline

Definition at line 83 of file ref_ptr.h.

84 : ptr_(r.ptr_) {
85 if (ptr_) {
86 ptr_->AddRef();
87 }
88 }

◆ RefPtr() [5/7]

template<typename T >
template<typename U >
fml::RefPtr< T >::RefPtr ( const RefPtr< U > &  r)
inline

Definition at line 91 of file ref_ptr.h.

92 : ptr_(r.ptr_) {
93 if (ptr_) {
94 ptr_->AddRef();
95 }
96 }

◆ RefPtr() [6/7]

template<typename T >
fml::RefPtr< T >::RefPtr ( RefPtr< T > &&  r)
inline

Definition at line 99 of file ref_ptr.h.

99 : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
100 r.ptr_ = nullptr;
101 }

◆ RefPtr() [7/7]

template<typename T >
template<typename U >
fml::RefPtr< T >::RefPtr ( RefPtr< U > &&  r)
inline

Definition at line 104 of file ref_ptr.h.

104 : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
105 r.ptr_ = nullptr;
106 }

◆ ~RefPtr()

template<typename T >
fml::RefPtr< T >::~RefPtr ( )
inline

Definition at line 109 of file ref_ptr.h.

109 {
110 // NOLINTNEXTLINE(clang-analyzer-core.StackAddressEscape)
111 if (ptr_) {
112 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete,clang-analyzer-core.StackAddressEscape)
113 ptr_->Release();
114 }
115 }

Member Function Documentation

◆ Clone()

template<typename T >
RefPtr< T > fml::RefPtr< T >::Clone ( ) const
inline

Definition at line 189 of file ref_ptr.h.

189{ return *this; }

Referenced by fml::WeakPtrFactory< T >::GetWeakPtr(), and fml::TaskRunnerAffineWeakPtrFactory< T >::GetWeakPtr().

◆ get()

◆ operator bool()

template<typename T >
fml::RefPtr< T >::operator bool ( ) const
inlineexplicit

Definition at line 191 of file ref_ptr.h.

191{ return !!ptr_; }

◆ operator!=()

template<typename T >
template<typename U >
bool fml::RefPtr< T >::operator!= ( const RefPtr< U > &  rhs) const
inline

Definition at line 199 of file ref_ptr.h.

199 {
200 return !operator==(rhs);
201 }
bool operator==(const RefPtr< U > &rhs) const
Definition ref_ptr.h:194

References fml::RefPtr< T >::operator==().

◆ operator*()

template<typename T >
T & fml::RefPtr< T >::operator* ( ) const
inline

Definition at line 119 of file ref_ptr.h.

119 {
120 FML_DCHECK(ptr_);
121 return *ptr_;
122 }
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK.

◆ operator->()

template<typename T >
T * fml::RefPtr< T >::operator-> ( ) const
inline

Definition at line 124 of file ref_ptr.h.

124 {
125 FML_DCHECK(ptr_);
126 return ptr_;
127 }

References FML_DCHECK.

◆ operator<()

template<typename T >
template<typename U >
bool fml::RefPtr< T >::operator< ( const RefPtr< U > &  rhs) const
inline

Definition at line 204 of file ref_ptr.h.

204 {
205 return ptr_ < rhs.ptr_;
206 }

◆ operator=() [1/4]

template<typename T >
RefPtr< T > & fml::RefPtr< T >::operator= ( const RefPtr< T > &  r)
inline

Definition at line 130 of file ref_ptr.h.

130 {
131 // Handle self-assignment.
132 if (r.ptr_ == ptr_) {
133 return *this;
134 }
135 if (r.ptr_) {
136 r.ptr_->AddRef();
137 }
138 T* old_ptr = ptr_;
139 ptr_ = r.ptr_;
140 if (old_ptr) {
141 old_ptr->Release();
142 }
143 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
144 return *this;
145 }

◆ operator=() [2/4]

template<typename T >
template<typename U >
RefPtr< T > & fml::RefPtr< T >::operator= ( const RefPtr< U > &  r)
inline

Definition at line 148 of file ref_ptr.h.

148 {
149 if (reinterpret_cast<T*>(r.ptr_) == ptr_) {
150 return *this;
151 }
152 if (r.ptr_) {
153 r.ptr_->AddRef();
154 }
155 T* old_ptr = ptr_;
156 ptr_ = r.ptr_;
157 if (old_ptr) {
158 old_ptr->Release();
159 }
160 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
161 return *this;
162 }

◆ operator=() [3/4]

template<typename T >
RefPtr< T > & fml::RefPtr< T >::operator= ( RefPtr< T > &&  r)
inline

Definition at line 167 of file ref_ptr.h.

167 {
168 RefPtr<T>(std::move(r)).swap(*this);
169 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
170 return *this;
171 }

References fml::RefPtr< T >::swap().

◆ operator=() [4/4]

template<typename T >
template<typename U >
RefPtr< T > & fml::RefPtr< T >::operator= ( RefPtr< U > &&  r)
inline

Definition at line 174 of file ref_ptr.h.

174 {
175 RefPtr<T>(std::move(r)).swap(*this);
176 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
177 return *this;
178 }

References fml::RefPtr< T >::swap().

◆ operator==()

template<typename T >
template<typename U >
bool fml::RefPtr< T >::operator== ( const RefPtr< U > &  rhs) const
inline

Definition at line 194 of file ref_ptr.h.

194 {
195 return ptr_ == rhs.ptr_;
196 }

Referenced by fml::RefPtr< T >::operator!=().

◆ swap()

template<typename T >
void fml::RefPtr< T >::swap ( RefPtr< T > &  r)
inline

Definition at line 180 of file ref_ptr.h.

180 {
181 T* p = ptr_;
182 ptr_ = r.ptr_;
183 r.ptr_ = p;
184 }

Referenced by fml::RefPtr< T >::operator=(), and fml::RefPtr< T >::operator=().

Friends And Related Symbol Documentation

◆ AdoptRef

template<typename T >
RefPtr< T > AdoptRef ( T *  )
friend

Definition at line 227 of file ref_ptr.h.

227 {
228#ifndef NDEBUG
229 ptr->Adopt();
230#endif
231 return RefPtr<T>(ptr, RefPtr<T>::kAdopt);
232}

◆ RefPtr

template<typename T >
template<typename U >
friend class RefPtr
friend

Definition at line 210 of file ref_ptr.h.


The documentation for this class was generated from the following file: