|
Chromium Embedded Framework (CEF)
145.0.1+g472e75d+chromium-145.0.7632.5
|
The WeakPtr class holds a weak reference to |T*|. More...
#include "include/base/cef_weak_ptr.h"
Public Member Functions | |
| WeakPtr ()=default | |
| WeakPtr (std::nullptr_t) | |
| template<typename U > | |
| requires (std::convertible_to< U *, T * >) WeakPtr(const WeakPtr< U > &other) | |
| Allow conversion from U to T provided U "is a" T. More... | |
| template<typename U > | |
| requires (std::convertible_to< U *, T * >) WeakPtr &operator | |
| ptr_ (std::move(other.ptr_)) | |
| template<typename U > | |
| requires (std::convertible_to< U *, T * >) WeakPtr &operator | |
| WeakPtr (cef_internal::WeakReference &&ref, T *ptr) | |
| cef_internal::WeakReference | CloneWeakReference () const |
Public Attributes | |
| cef_internal::WeakReference | ref_ |
| T * | ptr_ = nullptr |
Friends | |
| class | WeakPtrFactory< T > |
| class | WeakPtrFactory< std::remove_const_t< T > > |
The WeakPtr class holds a weak reference to |T*|.
This class is designed to be used like a normal pointer. You should always null-test an object of this class before using it or invoking a method that may result in the underlying object being destroyed.
EXAMPLE:
class Foo { ... };
WeakPtr<Foo> foo;
if (foo)
foo->method();
WeakPtr intentionally doesn't implement operator== or operator<=>, because comparisons of weak references are inherently unstable. If the comparison takes validity into account, the result can change at any time as pointers are invalidated. If it depends only on the underlying pointer value, even after the pointer is invalidated, unrelated WeakPtrs can unexpectedly compare equal if the address is reused.
|
default |
|
inline |
|
inline |
|
inline |
|
inline |
| base::WeakPtr< T >::requires | ( | std::convertible_to< U *, T * > | ) | & |
| base::WeakPtr< T >::requires | ( | std::convertible_to< U *, T * > | ) | & |
|
inline |
Allow conversion from U to T provided U "is a" T.
Note that this is separate from the (implicit) copy and move constructors.
|
friend |
|
friend |
| T* base::WeakPtr< T >::ptr_ = nullptr |
| cef_internal::WeakReference base::WeakPtr< T >::ref_ |