![]() |
ezEngine Release 25.08
|
A Shared ptr manages a shared object and destroys that object when no one references it anymore. The managed object must derive from ezRefCounted. More...
#include <SharedPtr.h>
Public Member Functions | |
| EZ_DECLARE_MEM_RELOCATABLE_TYPE () | |
| ezSharedPtr () | |
| Creates an empty shared ptr. | |
| template<typename U > | |
| ezSharedPtr (const ezInternal::NewInstance< U > &instance) | |
| Creates a shared ptr from a freshly created instance through EZ_NEW or EZ_DEFAULT_NEW. | |
| template<typename U > | |
| ezSharedPtr (U *pInstance, ezAllocator *pAllocator) | |
| Creates a shared ptr from a pointer and an allocator. The passed allocator will be used to destroy the instance when the shared ptr goes out of scope. | |
| ezSharedPtr (const ezSharedPtr< T > &other) | |
| Copy constructs a shared ptr from another. Both will hold a reference to the managed object afterwards. | |
| template<typename U > | |
| ezSharedPtr (const ezSharedPtr< U > &other) | |
| Copy constructs a shared ptr from another. Both will hold a reference to the managed object afterwards. | |
| template<typename U > | |
| ezSharedPtr (ezSharedPtr< U > &&other) | |
| Move constructs a shared ptr from another. The other shared ptr will be empty afterwards. | |
| template<typename U > | |
| ezSharedPtr (ezUniquePtr< U > &&other) | |
| Move constructs a shared ptr from a unique ptr. The unique ptr will be empty afterwards. | |
| ezSharedPtr (std::nullptr_t) | |
| Initialization with nullptr to be able to return nullptr in functions that return shared ptr. | |
| ~ezSharedPtr () | |
| Destroys the managed object using the stored allocator if no one else references it anymore. | |
| template<typename U > | |
| ezSharedPtr< T > & | operator= (const ezInternal::NewInstance< U > &instance) |
| Sets the shared ptr from a freshly created instance through EZ_NEW or EZ_DEFAULT_NEW. | |
| ezSharedPtr< T > & | operator= (const ezSharedPtr< T > &other) |
| Sets the shared ptr from another. Both will hold a reference to the managed object afterwards. | |
| template<typename U > | |
| ezSharedPtr< T > & | operator= (const ezSharedPtr< U > &other) |
| Sets the shared ptr from another. Both will hold a reference to the managed object afterwards. | |
| template<typename U > | |
| ezSharedPtr< T > & | operator= (ezSharedPtr< U > &&other) |
| Move assigns a shared ptr from another. The other shared ptr will be empty afterwards. | |
| template<typename U > | |
| ezSharedPtr< T > & | operator= (ezUniquePtr< U > &&other) |
| Move assigns a shared ptr from a unique ptr. The unique ptr will be empty afterwards. | |
| ezSharedPtr< T > & | operator= (std::nullptr_t) |
| Assigns a nullptr to the shared ptr. Same as Reset. | |
| T * | Borrow () const |
| Borrows the managed object. The shared ptr stays unmodified. | |
| void | Clear () |
| Destroys the managed object if no one else references it anymore and resets the shared ptr. | |
| T & | operator* () const |
| Provides access to the managed object. | |
| T * | operator-> () const |
| Provides access to the managed object. | |
| operator const T * () const | |
| Provides access to the managed object. | |
| operator T* () | |
| Provides access to the managed object. | |
| operator bool () const | |
| Returns true if there is managed object and false if the shared ptr is empty. | |
| bool | operator== (const ezSharedPtr< T > &rhs) const |
| Compares the shared ptr against another shared ptr. | |
| bool | operator!= (const ezSharedPtr< T > &rhs) const |
| bool | operator< (const ezSharedPtr< T > &rhs) const |
| bool | operator<= (const ezSharedPtr< T > &rhs) const |
| bool | operator> (const ezSharedPtr< T > &rhs) const |
| bool | operator>= (const ezSharedPtr< T > &rhs) const |
| bool | operator== (std::nullptr_t) const |
| Compares the shared ptr against nullptr. | |
| bool | operator!= (std::nullptr_t) const |
| bool | operator< (std::nullptr_t) const |
| bool | operator<= (std::nullptr_t) const |
| bool | operator> (std::nullptr_t) const |
| bool | operator>= (std::nullptr_t) const |
| template<typename DERIVED > | |
| ezSharedPtr< DERIVED > | Downcast () const |
| Returns a copy of this, as an ezSharedPtr<DERIVED>. Downcasts the stored pointer (using static_cast). | |
| template<typename U > | |
| EZ_ALWAYS_INLINE | ezSharedPtr (const ezInternal::NewInstance< U > &instance) |
| template<typename U > | |
| EZ_ALWAYS_INLINE | ezSharedPtr (U *pInstance, ezAllocator *pAllocator) |
| template<typename U > | |
| EZ_ALWAYS_INLINE | ezSharedPtr (const ezSharedPtr< U > &other) |
| template<typename U > | |
| EZ_ALWAYS_INLINE | ezSharedPtr (ezSharedPtr< U > &&other) |
| template<typename U > | |
| EZ_ALWAYS_INLINE | ezSharedPtr (ezUniquePtr< U > &&other) |
| template<typename U > | |
| EZ_ALWAYS_INLINE ezSharedPtr< T > & | operator= (const ezInternal::NewInstance< U > &instance) |
| template<typename U > | |
| EZ_ALWAYS_INLINE ezSharedPtr< T > & | operator= (const ezSharedPtr< U > &other) |
| template<typename U > | |
| EZ_ALWAYS_INLINE ezSharedPtr< T > & | operator= (ezSharedPtr< U > &&other) |
| template<typename U > | |
| EZ_ALWAYS_INLINE ezSharedPtr< T > & | operator= (ezUniquePtr< U > &&other) |
A Shared ptr manages a shared object and destroys that object when no one references it anymore. The managed object must derive from ezRefCounted.
|
inline |
Returns a copy of this, as an ezSharedPtr<DERIVED>. Downcasts the stored pointer (using static_cast).
Does not check whether the cast would be valid, that is all your responsibility.