CsPointer
2.0.0
|
Stores a weak pointer to a potentially shared object. More...
Public Typedefs | |
using | element_type = typename std::weak_ptr< T >::element_type |
using | pointer = element_type * |
using | Pointer = pointer |
using | ElementType = element_type |
Public Member Functions | |
CsWeakPointer () | |
template<typename U > | |
CsWeakPointer (const CsWeakPointer< U > &p) noexcept | |
template<typename U > | |
CsWeakPointer (const CsSharedPointer< U > &p) noexcept | |
~CsWeakPointer () = default | |
CsWeakPointer (const CsWeakPointer &other) = default | |
CsWeakPointer & | operator= (const CsWeakPointer &other) = default |
CsWeakPointer (CsWeakPointer &&other) = default | |
CsWeakPointer & | operator= (CsWeakPointer &&other) = default |
template<typename U > | |
CsWeakPointer & | operator= (const CsSharedPointer< U > &p) noexcept |
bool | operator! () const |
operator bool () const noexcept | |
void | clear () noexcept |
bool | expired () const noexcept |
CsSharedPointer< T > | lock () const noexcept |
bool | is_null () const noexcept |
template<typename U > | |
bool | owner_before (const CsSharedPointer< U > &p) const noexcept |
template<typename U > | |
bool | owner_before (const CsWeakPointer< U > &p) const noexcept |
void | reset () noexcept |
void | swap (CsWeakPointer &other) noexcept |
CsSharedPointer< T > | toStrongRef () const noexcept |
long | use_count () const noexcept |
Related Functions | |
These are not member functions | |
bool | operator!= (const CsWeakPointer< T1 > &ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator!= (const CsSharedPointer< T1 > &ptr1, const CsWeakPointer< T2 > &ptr2) |
bool | operator== (const CsWeakPointer< T1 > &ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator== (const CsSharedPointer< T1 > &ptr1, const CsWeakPointer< T2 > &ptr2) |
The CsWeakPointer class stores a weak pointer to a potentially shared object. A weak pointer is a smart pointer which does take ownership or manage the lifetime of the shared object. A CsWeakPointer can only be created by calling CsSharedPointer::toWeakRef() or using the constructor in CsWeakPointer which accepts a CsSharedPointer.
To access the object which CsWeakPointer points to, convert it to CsSharedPointer and ensure the shared pointer is not a nullptr. If the shared pointer is not a nullptr, the object will not be deleted while the shared pointer is in scope.
CsWeakPointer::element_type |
Typedef for std::weak_ptr<T>::element_type.
CsWeakPointer::ElementType |
Typedef for element_type.
CsWeakPointer::pointer |
Typedef for element_type *.
CsWeakPointer::Pointer |
Typedef for pointer.
|
inline |
Creates a new CsWeakPointer which contains a nullptr.
|
inlinenoexcept |
Creates a new CsWeakPointer from p. The template parameter U must inherit from T.
|
inlinenoexcept |
Constructs a new CsWeakPointer from the shared pointer p.
|
default |
Destroys this CsWeakPointer object. The object this pointer points to will not be deleted.
|
default |
Copy constructs a new CsWeakPointer from other.
|
default |
Move constructs a new CsWeakPointer from other.
|
inlinenoexcept |
Sets this CsWeakPointer object to a nullptr. The object this pointer points to will not be deleted.
|
inlinenoexcept |
Equivalent to calling is_null().
|
inlinenoexcept |
Returns true if the current CsWeakPointer contains a nullptr. Since the object this weak pointer points to can be deleted at any time, a return value of true does not guarantee the object is still alive after calling this method.
|
inlinenoexcept |
Equivalent to calling toStrongRef().
|
inlineexplicitnoexcept |
Returns true if the current CsWeakPointer is not a nullptr. This method is called when a shared pointer is used in an "if statement" or another context where a boolean value is expected. Since this method is explicit it is not possible to assign a weak pointer to a boolean.
|
inline |
Returns true if this object is a nullptr. This method is called when a shared pointer is used in an "if statement" or another context where a boolean value is expected.
|
inlinenoexcept |
Assigns from the shared pointer p and returns a reference to this object.
|
default |
Copy assigns from other and returns a reference to this object.
|
default |
Move assigns from other and returns a reference to this object.
|
inlinenoexcept |
Returns true if the current pointer is less than p, otherwise returns false.
|
inlinenoexcept |
Returns true if the current pointer is less than p, otherwise returns false.
|
inlinenoexcept |
Equivalent to calling clear().
|
inlinenoexcept |
Swaps the current CsWeakPointer with other. This method is very fast and never fails.
|
inlinenoexcept |
Converts the current weak pointer to a shared pointer and returns the CsSharedPointer. This method can fail if the object the CsWeakPointer is pointing to has been deleted. To prevent undefined behavior verify the return value by calling CsSharedPointer::is_null() before dereferencing.
|
inlinenoexcept |
Returns the reference count for the current CsWeakPointer.
|
related |
Returns true if ptr1 and ptr2 do not point to the same object.
|
related |
Returns true if ptr1 and ptr2 do not point to the same object.
|
related |
Returns true if ptr1 and ptr2 point to the same object.
|
related |
Returns true if ptr1 and ptr2 point to the same object.