Rebel Fork Framework
Urho3D::WeakPtr< InterfaceType, RefCountedType > Class Template Reference

Weak pointer template class with intrusive reference counting. Does not keep the object pointed to alive. More...

#include <Urho3D/Container/Ptr.h>

Inheritance diagram for Urho3D::WeakPtr< InterfaceType, RefCountedType >:
Urho3D::Detail::WeakPtrBase< InterfaceType, InterfaceType >

Public Types

using ThisType = WeakPtr<InterfaceType, RefCountedType>
using BaseType = Detail::WeakPtrBase<InterfaceType, RefCountedType>
using SharedPtrType = SharedPtr<InterfaceType, RefCountedType>

Public Member Functions

 WeakPtr (std::nullptr_t) noexcept
 WeakPtr (const ThisType &rhs) noexcept=default
 WeakPtr (ThisType &&rhs) noexcept=default
 WeakPtr (RefCount *refCount, InterfaceType *ptr, const RefCounted *refCounted) noexcept
 Construct with explicit reference counter.
template<class U1, class U2>
 WeakPtr (const WeakPtr< U1, U2 > &rhs) noexcept
 Copy-construct from another weak pointer allowing implicit upcasting.
template<class U1, class U2>
 WeakPtr (const SharedPtr< U1, U2 > &rhs) noexcept
 Construct from a shared pointer.
template<class U, ea::enable_if_t< ea::is_base_of_v< InterfaceType, U >, int > = 0>
 WeakPtr (U *ptr) noexcept
 Construct from a raw pointer.
template<class U1, class U2>
ThisType & operator= (const SharedPtr< U1, U2 > &rhs) noexcept
 Assign from a shared pointer.
ThisType & operator= (const ThisType &rhs) noexcept
 Assign from another weak pointer.
template<class U1, class U2>
ThisType & operator= (const WeakPtr< U1, U2 > &rhs) noexcept
 Assign from another weak pointer.
ThisType & operator= (ThisType &&rhs) noexcept
 Move-assign from another weak pointer.
template<class U>
ThisType & operator= (U *ptr) noexcept
 Assign from a raw pointer.
SharedPtrType Lock () const noexcept
 Convert to a shared pointer. If expired, return a null shared pointer.
InterfaceType * Get () const noexcept
 Return raw pointer. If expired, return null.
InterfaceType * operator-> () const noexcept
 Point to the object.
InterfaceType & operator* () const noexcept
 Dereference the object.
template<class U1, class U2>
bool operator== (const WeakPtr< U1, U2 > &rhs) const noexcept
 Test for equality with another weak pointer.
template<class U1, class U2>
bool operator!= (const WeakPtr< U1, U2 > &rhs) const noexcept
 Test for inequality with another weak pointer.
template<class U1, class U2>
bool operator< (const WeakPtr< U1, U2 > &rhs) const noexcept
 operator InterfaceType * () const noexcept
 Convert to a raw pointer, null if the object is expired.
void Reset () noexcept
 Reset.
template<class U>
void Reset (U *ptr) noexcept
 Reset with another pointer.
void Reset (RefCount *refCount, InterfaceType *ptr, const RefCounted *refCounted) noexcept
 Reset with another pointers.
template<class U1, class U2>
void StaticCast (const WeakPtr< U1, U2 > &rhs) noexcept
 Perform a static cast from a weak pointer of another type.
template<class U1, class U2>
void DynamicCast (const WeakPtr< U1, U2 > &rhs) noexcept
 Perform a dynamic cast from a weak pointer of another type.
size_t ToHash () const noexcept
 Return hash value for HashSet & HashMap. Use the same hash function as for raw pointers!

Detailed Description

template<class InterfaceType, class RefCountedType = InterfaceType>
class Urho3D::WeakPtr< InterfaceType, RefCountedType >

Weak pointer template class with intrusive reference counting. Does not keep the object pointed to alive.

Member Function Documentation

◆ operator<()

template<class InterfaceType, class RefCountedType = InterfaceType>
template<class U1, class U2>
bool Urho3D::WeakPtr< InterfaceType, RefCountedType >::operator< ( const WeakPtr< U1, U2 > & rhs) const
inlinenoexcept

Test for less than with another weak pointer. Weak pointers sharing the same control block are equivalent.


The documentation for this class was generated from the following file:
  • Urho3D/Container/Ptr.h