Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
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 ()
 
Tget () const
 
Toperator* () const
 
Toperator-> () 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< TClone () 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< TAdoptRef (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 if (ptr_) {
111 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete)
112 ptr_->Release();
113 }
114 }

Member Function Documentation

◆ Clone()

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

Definition at line 184 of file ref_ptr.h.

184{ return *this; }

◆ get()

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

Definition at line 116 of file ref_ptr.h.

116{ return ptr_; }

◆ operator bool()

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

Definition at line 186 of file ref_ptr.h.

186{ return !!ptr_; }

◆ 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 !operator==(rhs);
196 }
bool operator==(const RefPtr< U > &rhs) const
Definition ref_ptr.h:189

◆ operator*()

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

Definition at line 118 of file ref_ptr.h.

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

◆ operator->()

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

Definition at line 123 of file ref_ptr.h.

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

◆ 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 ptr_ < rhs.ptr_;
201 }

◆ operator=() [1/4]

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

Definition at line 129 of file ref_ptr.h.

129 {
130 // Handle self-assignment.
131 if (r.ptr_ == ptr_) {
132 return *this;
133 }
134 if (r.ptr_) {
135 r.ptr_->AddRef();
136 }
137 T* old_ptr = ptr_;
138 ptr_ = r.ptr_;
139 if (old_ptr) {
140 old_ptr->Release();
141 }
142 return *this;
143 }
#define T

◆ operator=() [2/4]

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

Definition at line 146 of file ref_ptr.h.

146 {
147 if (reinterpret_cast<T*>(r.ptr_) == ptr_) {
148 return *this;
149 }
150 if (r.ptr_) {
151 r.ptr_->AddRef();
152 }
153 T* old_ptr = ptr_;
154 ptr_ = r.ptr_;
155 if (old_ptr) {
156 old_ptr->Release();
157 }
158 return *this;
159 }

◆ operator=() [3/4]

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

Definition at line 164 of file ref_ptr.h.

164 {
165 RefPtr<T>(std::move(r)).swap(*this);
166 return *this;
167 }

◆ operator=() [4/4]

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

Definition at line 170 of file ref_ptr.h.

170 {
171 RefPtr<T>(std::move(r)).swap(*this);
172 return *this;
173 }

◆ operator==()

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

Definition at line 189 of file ref_ptr.h.

189 {
190 return ptr_ == rhs.ptr_;
191 }

◆ swap()

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

Definition at line 175 of file ref_ptr.h.

175 {
176 T* p = ptr_;
177 ptr_ = r.ptr_;
178 r.ptr_ = p;
179 }

Friends And Related Symbol Documentation

◆ AdoptRef

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

Definition at line 222 of file ref_ptr.h.

222 {
223#ifndef NDEBUG
224 ptr->Adopt();
225#endif
226 return RefPtr<T>(ptr, RefPtr<T>::kAdopt);
227}

◆ RefPtr

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

Definition at line 205 of file ref_ptr.h.


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