U3D
Open-source, cross-platform 2D and 3D game engine built in C++
Loading...
Searching...
No Matches
Urho3D::SharedPtr< T > Class Template Reference

Shared pointer template class with intrusive reference counting. More...

#include </var/dev/u3d/stable/Source/Urho3D/Container/Ptr.h>

Public Member Functions

 SharedPtr () noexcept
 Construct a null shared pointer.
 
 SharedPtr (std::nullptr_t) noexcept
 Construct a null shared pointer.
 
 SharedPtr (const SharedPtr< T > &rhs) noexcept
 Copy-construct from another shared pointer.
 
 SharedPtr (SharedPtr< T > &&rhs) noexcept
 Move-construct from another shared pointer.
 
template<class U >
 SharedPtr (const SharedPtr< U > &rhs) noexcept
 Copy-construct from another shared pointer allowing implicit upcasting.
 
 SharedPtr (T *ptr) noexcept
 Construct from a raw pointer.
 
 ~SharedPtr () noexcept
 Destruct. Release the object reference.
 
SharedPtr< T > & operator= (const SharedPtr< T > &rhs)
 Assign from another shared pointer.
 
SharedPtr< T > & operator= (SharedPtr< T > &&rhs)
 Move-assign from another shared pointer.
 
template<class U >
SharedPtr< T > & operator= (const SharedPtr< U > &rhs)
 Assign from another shared pointer allowing implicit upcasting.
 
SharedPtr< T > & operator= (T *ptr)
 Assign from a raw pointer.
 
T * operator-> () const
 Point to the object.
 
T & operator* () const
 Dereference the object.
 
T & operator[] (int index)
 Subscript the object if applicable.
 
template<class U >
bool operator< (const SharedPtr< U > &rhs) const
 Test for less than with another shared pointer.
 
template<class U >
bool operator== (const SharedPtr< U > &rhs) const
 Test for equality with another shared pointer.
 
template<class U >
bool operator!= (const SharedPtr< U > &rhs) const
 Test for inequality with another shared pointer.
 
 operator T* () const
 Convert to a raw pointer.
 
void Swap (SharedPtr< T > &rhs)
 Swap with another SharedPtr.
 
void Reset (T *ptr=nullptr)
 Reset with another pointer.
 
T * Detach ()
 Detach without destroying the object even if the refcount goes zero. To be used for scripting language interoperation.
 
template<class U >
void StaticCast (const SharedPtr< U > &rhs)
 Perform a static cast from a shared pointer of another type.
 
template<class U >
void DynamicCast (const SharedPtr< U > &rhs)
 Perform a dynamic cast from a shared pointer of another type.
 
bool Null () const
 Check if the pointer is null.
 
bool NotNull () const
 Check if the pointer is not null.
 
T * Get () const
 Return the raw pointer.
 
int Refs () const
 Return the object's reference count, or 0 if the pointer is null.
 
int WeakRefs () const
 Return the object's weak reference count, or 0 if the pointer is null.
 
RefCountRefCountPtr () const
 Return pointer to the RefCount structure.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 

Private Member Functions

void AddRef ()
 Add a reference to the object pointed to.
 
void ReleaseRef ()
 Release the object reference and delete it if necessary.
 

Private Attributes

T * ptr_
 Pointer to the object.
 

Detailed Description

template<class T>
class Urho3D::SharedPtr< T >

Shared pointer template class with intrusive reference counting.


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