Thread‐safe reference‐counted smart pointer with shared ownership.
Synopsis
Declared in <bslstl_sharedptr.h>
template<class ELEMENT_TYPE>
class shared_ptr;
Description
This class provides a thread‐safe reference‐counted "smart pointer" to support "shared ownership" of objects: a shared pointer ensures that the shared object is destroyed, using the appropriate deletion method, only when there are no shared references to it. The object (of template parameter type ELEMENT_TYPE) referred to by a shared pointer may be accessed directly using the ‐> operator, or the dereference operator (operator *) can be used to obtain a reference to that object.
Note that the object referred to by a shared pointer representation is usually the same as the object referred to by that shared pointer (of the same ELEMENT_TYPE), but this need not always be true in the presence of conversions or "aliasing": the object referred to (of template parameter type ELEMENT_TYPE) by the shared pointer may differ from the object of type COMPATIBLE_TYPE (see the "Aliasing" section in the component‐level documentation) referred to by the shared pointer representation.
More generally, this class supports a complete set of in‐_core_ pointer semantic operations.
Type Aliases
Name |
Description |
Alias to the element type managed by this |
|
|
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this |
Assignment operators |
|
Reset this |
|
|
|
Return the address providing modifiable access to the object referred to by this shared pointer, or 0 if this shared pointer does not refer to an object. |
|
|
|
Reset this |
|
Return a |
|
Return a "snapshot" of the number of shared pointers (including this one) that share ownership of the object managed by this shared pointer. |
|
Return a reference providing modifiable access to the object referred to by this shared pointer. |
|
Return the address providing modifiable access to the object referred to by this shared pointer, or 0 if this shared pointer does not refer to an object. |
|
Return a reference to the element at the specified |
|
Return whether this |
|
Return whether this pointer shares ownership with |
|
Return a hash value based on this pointer's ownership identity. |
|
Return the address providing modifiable access to the object referred to by this shared pointer, or 0 if this shared pointer does not refer to an object. |
|
Release ownership and return the pointer and representation addresses. |
|
Return the address providing modifiable access to the |
|
|
|
Exchange the state of this |
|
Return whether this |
|
Return a "snapshot" of the number of shared pointers (including this one) that share ownership of the object managed by this shared pointer. |
|
Nested trait declaration for |
|
Return whether this |
Deduction Guides
Name |
Description |
Deduce the specified type |
|
Deduce the specified type |
|
Deduce the specified type |
|
Deduction guide for constructing |
|
Deduction guide for constructing |
Friends
Name |
Description |
|
Thread‐safe reference‐counted smart pointer with shared ownership. |
Non-Member Functions
Name |
Description |
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a pointer to the deleter of type |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Perform a three‐way comparison of the specified |
|
Compare |
|
Return whether |
|
Return |
|
Return a |
|
Return a |
|
Exchange the states of the specified |
Created with MrDocs