std::shared_ptr
From Cppreference
| Defined in header <memory>
|
||
| template< class T > class shared_ptr;
|
(since C++11) | |
std::shared_ptr is a smart pointer that manages lifetime of an object, typically allocated with new. Several shared_ptr objects may manage the same object; the object is destroyed when the last remaining shared_ptr pointing to it is destroyed or reset. The object is destroyed using delete-expression or a custom deleter that is supplied to shared_ptr during construction.
Contents |
[edit] Member types
| Member type | Definition |
| element_type | T |
[edit] Member functions
| constructs new shared_ptr (public member function) |
|
| destructs the owned object if no more shared_ptrs link to it (public member function) |
|
| assigns the shared_ptr (public member function) |
|
Modifiers | |
| replaces the managed object (public member function) |
|
| swaps the managed objects (public member function) |
|
Observers | |
| returns a pointer to the managed object (public member function) |
|
| dereferences pointer to the managed object (public member function) |
|
| returns the number of shared_ptr objects referring to the same managed object (public member function) |
|
| checks whether the managed object is managed only by the current shared_ptr instance (public member function) |
|
| checks if there is associated managed object (public member function) |
|
| provides owner-based ordering of shared pointers (public member function) |
|
[edit] Non-member functions
| creates a shared pointer that manages a new object (function template) |
|
| creates a shared pointer that manages a new object allocated using an allocator (function template) |
|
| applies static_cast, dynamic_cast or const_cast to the type of the managed object (function template) |
|
| returns the deleter of specified type, if owned (function template) |
|
| compares with another shared_ptr or with nullptr (function template) |
|
| outputs the value of the managed pointer to an output stream (function template) |
|
| (C++11)
|
specializes the std::swap algorithm (function template) |
| specializes atomic operations (function template) |
|
[edit] Helper classes
| (C++11)
|
hash support for std::shared_ptr (class template specialization) |