CsPointer
1.0.1
|
Stores a pointer to a potentially shared object. More...
Public Typedefs | |
using | element_type = typename std::shared_ptr< T >::element_type |
using | weak_type = CsWeakPointer< T > |
using | pointer = element_type * |
using | ElementType = element_type |
using | WeakType = weak_type |
using | Pointer = pointer |
Public Member Functions | |
constexpr | CsSharedPointer () noexcept |
constexpr | CsSharedPointer (std::nullptr_t) noexcept |
template<typename U > | |
CsSharedPointer (U *p) | |
template<typename U , typename Deleter > | |
CsSharedPointer (U *p, Deleter d) | |
template<typename Deleter > | |
CsSharedPointer (std::nullptr_t, Deleter d) | |
template<typename U , typename Deleter , typename Alloc > | |
CsSharedPointer (U *p, Deleter d, Alloc a) | |
template<typename Deleter , typename Alloc > | |
CsSharedPointer (std::nullptr_t, Deleter d, Alloc a) | |
template<typename U , typename Deleter > | |
CsSharedPointer (CsUniquePointer< U, Deleter > &&p) | |
template<typename U > | |
CsSharedPointer (const std::shared_ptr< U > &p) noexcept | |
template<typename U > | |
CsSharedPointer (std::shared_ptr< U > &&p) noexcept | |
template<typename U > | |
CsSharedPointer (const CsSharedPointer< U > &p1, element_type *p2) noexcept | |
template<typename U > | |
CsSharedPointer (CsSharedPointer< U > &&p1, element_type *p2) noexcept | |
~CsSharedPointer () = default | |
CsSharedPointer (const CsSharedPointer &other) = default | |
CsSharedPointer & | operator= (const CsSharedPointer &other) = default |
CsSharedPointer (CsSharedPointer &&other) = default | |
CsSharedPointer & | operator= (CsSharedPointer &&other) = default |
template<typename U > | |
CsSharedPointer (const CsSharedPointer< U > &p) noexcept | |
template<typename U > | |
CsSharedPointer & | operator= (const CsSharedPointer< U > &p) noexcept |
template<typename U > | |
CsSharedPointer (CsSharedPointer< U > &&p) noexcept | |
template<typename U > | |
CsSharedPointer & | operator= (CsSharedPointer< U > &&p) noexcept |
template<typename U > | |
CsSharedPointer (const CsWeakPointer< U > &p) | |
template<typename U > | |
CsSharedPointer & | operator= (const CsWeakPointer< U > &p) |
element_type & | operator* () const noexcept |
pointer | operator-> () const noexcept |
bool | operator! () const noexcept |
operator bool () const noexcept | |
template<typename U > | |
operator std::shared_ptr< U > () const &noexcept | |
template<typename U > | |
operator std::shared_ptr< U > () &&noexcept | |
void | clear () noexcept |
pointer | data () const noexcept |
pointer | get () 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 |
template<typename U > | |
void | reset (U *p) |
template<typename U , typename Deleter > | |
void | reset (U *p, Deleter d) |
template<typename U , typename Deleter , typename Alloc > | |
void | reset (U *p, Deleter d, Alloc a) |
void | swap (CsSharedPointer &other) noexcept |
CsWeakPointer< T > | toWeakRef () const |
bool | unique () const noexcept |
long | use_count () const noexcept |
Static Public Member Functions | |
template<typename... Args> | |
static CsSharedPointer< T > | create (Args &&...args) |
Related Functions | |
These are not member functions | |
CsSharedPointer< T > | make_shared (Args &&...args) |
CsSharedPointer< T > | const_pointer_cast (const CsSharedPointer< U > &ptr) |
CsSharedPointer< T > | dynamic_pointer_cast (const CsSharedPointer< U > &ptr) |
CsSharedPointer< T > | static_pointer_cast (const CsSharedPointer< U > &ptr) |
CsSharedPointer< T > | const_pointer_cast (CsSharedPointer< U > &&ptr) |
CsSharedPointer< T > | dynamic_pointer_cast (CsSharedPointer< U > &&ptr) |
CsSharedPointer< T > | static_pointer_cast (CsSharedPointer< U > &&ptr) |
bool | operator== (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator== (const CsSharedPointer< T1 > &ptr1, const T2 *ptr2) |
bool | operator== (const T1 *ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator== (const CsSharedPointer< T > &ptr1, std::nullptr_t) noexcept |
bool | operator== (std::nullptr_t, const CsSharedPointer< T > &ptr2) noexcept |
bool | operator!= (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator!= (const CsSharedPointer< T1 > &ptr1, const T2 *ptr2) |
bool | operator!= (const T1 *ptr1, const CsSharedPointer< T2 > &ptr2) |
bool | operator!= (const CsSharedPointer< T > &ptr1, std::nullptr_t) noexcept |
bool | operator!= (std::nullptr_t, const CsSharedPointer< T > &ptr2) noexcept |
bool | operator< (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > ptr2) |
bool | operator<= (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > ptr2) |
bool | operator> (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > ptr2) |
bool | operator>= (const CsSharedPointer< T1 > &ptr1, const CsSharedPointer< T2 > ptr2) |
void | swap (CsSharedPointer< T > &ptr1, CsSharedPointer< T > &ptr2) noexcept |
The CsSharedPointer class stores a pointer to a potentially shared object. This class maintains a shared reference count which indicates how many shared pointers are pointing to the current object. Any pointer class which takes responsibility for the lifetime of the object it points to is considered a smart pointer.
A CsSharedPointer object can be constructed from a raw pointer, another CsSharedPointer object, or by a CsWeakPointer object. When this class is destroyed the object it points to will be deleted if no other shared pointers are pointing to the given object.
CsSharedPointer::element_type |
Typedef for std::shared_ptr<T>::element_type.
CsSharedPointer::ElementType |
Typedef for element_type.
CsSharedPointer::pointer |
Typedef for element_type *.
CsSharedPointer::Pointer |
Typedef for pointer.
CsSharedPointer::weak_type |
Typedef for CsWeakPointer<T>.
CsSharedPointer::WeakType |
Typedef for weak_type.
|
inlineconstexprnoexcept |
Creates a new CsSharedPointer which contains a nullptr.
|
inlineconstexprnoexcept |
Creates a new CsSharedPointer which contains a nullptr.
|
inlineexplicit |
Creates a new CsSharedPointer which points to p. Ownership of the object is transferred to the new shared pointer.
|
inline |
Creates a new CsSharedPointer which points to the given raw pointer p. Ownership of the object is transferred to the new shared pointer. The value for d is a deleter object and will be used when the shared pointer is being destroyed.
|
inline |
Creates a new CsSharedPointer which contains a nullptr. The value for d is a deleter object and will be used when the shared pointer is being destroyed.
|
inline |
Creates a new CsSharedPointer which points to p. Ownership of the object is transferred to the new shared pointer. The value for d is a deleter object and will be used when the shared pointer is being destroyed. The value for a is an allocator object and will be used when the shared pointer needs to allocate memory.
|
inline |
Creates a new CsSharedPointer which contains a nullptr. The value for d is a deleter object and will be used when the shared pointer is being destroyed. The value for a is an allocator object and will be used when the shared pointer needs to allocate memory.
|
inline |
Creates a new CsSharedPointer using the given unique pointer p. The unique pointer will be set to a nullptr.
|
inlinenoexcept |
Creates a new CsSharedPointer using the given C++ Standard Library shared pointer p.
|
inlinenoexcept |
Creates a new CsSharedPointer by moving from the given C++ Standard Library shared pointer p.
|
inlinenoexcept |
Creates a new CsSharedPointer which points to the object referenced by p2. The reference count for p1 is incremented by one. The reference count for the new shared pointer uses the reference count in p1. You must ensure p2 is not destroyed before p1.
|
inlinenoexcept |
Creates a new CsSharedPointer which points to the object referenced by p2. The reference count for p1 is incremented by one. The reference count for the new shared pointer uses the reference count in p1. You must ensure p2 is not destroyed before p1.
|
default |
Destroys this CsSharedPointer. If the current shared pointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
default |
Copy constructs a new CsSharedPointer from other. The current shared pointer shares ownership with other.
|
default |
Move constructs a new CsSharedPointer from other.
|
inlinenoexcept |
Constructs a new CsSharedPointer from p. This shared pointer shares ownership with other. The template parameter U must inherit from T.
|
inlinenoexcept |
Constructs a CsSharedPointer by moving the ownership from p. The template parameter U must inherit from T.
|
inlineexplicit |
Creates a CsSharedPointer by converting the weak pointer p to a shared pointer. The template parameter U must inherit from T.
|
inlinenoexcept |
Sets the current CsSharedPointer to a nullptr. If the current shared pointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
inlinestatic |
Creates a new CsSharedPointer pointing to a new object of type T. This method can be more efficient than calling new to create the object and using the constructor which accepts a raw pointer.
|
inlinenoexcept |
Returns the value of the pointer contained in this object.
|
inlinenoexcept |
Equivalent to calling data().
|
inlinenoexcept |
Returns true if the current CsSharedPointer contains a nullptr.
|
inlineexplicitnoexcept |
Returns true if the current CsSharedPointer 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 shared pointer to a boolean.
|
inlinenoexcept |
Converts the current CsSharedPointer to an std::shared_ptr.
|
inlinenoexcept |
Converts the current CsSharedPointer to an std::shared_ptr.
|
inlinenoexcept |
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 |
Returns a reference to the object the current CsSharedPointer is pointing to.
|
inlinenoexcept |
Returns a pointer to the object the current CsSharedPointer is pointing to.
|
default |
Copy assigns from other and returns a reference to this object. If the current shared pointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
inlinenoexcept |
Assigns from p and returns a reference to this object. The template parameter U must inherit from T.
If the current shared pointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
inline |
Converts the weak pointer p to a shared pointer and then assigns it to the current CsSharedPointer. The template parameter U must inherit from T.
If the current CsSharedPointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
default |
Move assigns from other and returns a reference to this object. If the current CsSharedPointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
inlinenoexcept |
Assigns by moving the ownership from p and returns a reference to this object. The template parameter U must inherit from T.
If the current shared pointer is not a nullptr, then the internal reference count is decremented. If the reference count is zero then the object it is pointing to will be destroyed.
|
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().
|
inline |
Resets the current CsSharedPointer object to point to p. The template parameter U must inherit from T.
|
inline |
Resets the current CsSharedPointer object to point to p and updates the Deleter to d. The template parameter U must inherit from T.
|
inline |
Resets the current CsSharedPointer object to point to p and updates the Deleter to d. The value for a is an allocator object and will be used when CsSharedPointer needs to allocate memory. The template parameter U must inherit from T.
|
inlinenoexcept |
Swaps the current CsSharedPointer with other. This method is very fast and never fails.
|
inline |
Returns a CsWeakPointer which shares the internal reference count with the current shared pointer.
|
inlinenoexcept |
Returns true if the use_count() is equal to one.
|
inlinenoexcept |
Returns the reference count for the current CsSharedPointer.
|
related |
Returns a CsSharedPointer which points to the same object as ptr. The shared pointer is cast from type T to type U using a const_cast.
|
related |
Returns a CsSharedPointer by moving from ptr. The shared pointer is cast from type T to type U using a const_cast.
|
related |
Returns a CsSharedPointer which points to the same object as ptr. The shared pointer is cast from type T to type U using a dynamic_cast.
The U must have the same cv-qualifiers (const and volatile) that T has. If you need to cast away either of these qualifiers then use const_pointer_cast().
|
related |
Returns a CsSharedPointer by moving from ptr. The shared pointer is cast from type T to type U using a dynamic_cast.
The U must have the same cv-qualifiers (const and volatile) that T has. If you need to cast away either of these qualifiers then use const_pointer_cast().
|
related |
This function constructs a new object of type T and returns a shared pointer to the newly created object in a single operation.
|
related |
Returns true if ptr1 is not a nullptr.
|
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 do not point to the same object.
|
related |
Returns true if ptr2 is not a nullptr.
|
related |
Returns true if the value of ptr1 is less than ptr2.
|
related |
Returns true if the value of ptr1 is less than or equal to ptr2.
|
related |
Returns true if ptr1 is a nullptr.
|
related |
Returns true if ptr1 and ptr2 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.
|
related |
Returns true if ptr2 is a nullptr.
|
related |
Returns true if the value of ptr1 is greater than ptr2.
|
related |
Returns true if the value of ptr1 is greater than or equal to ptr2.
|
related |
Returns a CsSharedPointer which points to the same object as ptr. The shared pointer is cast from type T to type U using a static_cast.
|
related |
Returns a CsSharedPointer by moving from ptr. The shared pointer is cast from type T to type U using a static_cast.
|
related |
Swaps ptr1 with ptr2. This method is very fast and never fails.