template<typename Type, typename Deleter>
class fcppt::shared_ptr< Type, Deleter >
A shared pointer class that gets the deleter as a template parameter.
A shared pointer shares ownership of a single pointer with other shared pointers. How many shared pointers actually own a pointer is kept track of as a reference count. Copying shared pointers increases the count by one, while destroying shared pointers decrases the count by one. If the count reaches zero, the object that is pointed to will be destroyed.
The class is implemented using std::shared_ptr, so it will inherit most of its traits. This means that the class also uses type erasure for its deleter and internal ref count.
- Template Parameters
-
| Type | The type the shared pointer points to |
| Deleter | A deleter class that must be callable with a pointer to Type. |
|
| template<typename Other> |
| | shared_ptr (Other *pointerpointer) |
| | Constructs a shared_ptr from a compatible pointer type.
|
| template<typename Other, typename Alloc> |
| | shared_ptr (Other *pointerpointer, Alloc const &allocator) |
| | Constructs a shared_ptr from a compatible pointer type and allocator.
|
| template<typename Other> |
| | shared_ptr (fcppt::weak_ptr< Other, Deleter > const &ref) |
| | Constructs a shared_ptr from a compatible weak_ptr.
|
| | shared_ptr (shared_ptr const &) |
| | shared_ptr (shared_ptr &&) noexcept |
| template<typename Other> |
| | shared_ptr (fcppt::shared_ptr< Other, Deleter > const &ref) |
| | Constructs a shared_ptr from a compatible shared_ptr.
|
template<typename Other>
requires std::is_same_v<Deleter, fcppt::default_deleter> |
| | shared_ptr (fcppt::shared_ptr< Other > const &ref, pointer data) |
| | Constructs a shared_ptr that shares ownership with another.
|
| template<typename Other> |
| | shared_ptr (std::unique_ptr< Other, Deleter > &&ref) |
| template<typename Other> |
| | shared_ptr (fcppt::unique_ptr< Other, Deleter > &&ref) |
| | Constructs a shared_ptr from a compatible unique_ptr.
|
| shared_ptr & | operator= (shared_ptr const &) |
| shared_ptr & | operator= (shared_ptr &&) noexcept |
| template<typename Other> |
| shared_ptr & | operator= (fcppt::shared_ptr< Other, Deleter > const &ref) |
| | Assigns a shared_ptr from a compatible shared_ptr.
|
| template<typename Other> |
| shared_ptr & | operator= (fcppt::unique_ptr< Other, Deleter > &&ref) |
| | Assigns a shared_ptr from a compatible unique_ptr.
|
| | ~shared_ptr () noexcept |
| | Destroys this shared_ptr.
|
| reference | operator* () const |
| | Dereferences the owned pointer.
|
| pointer | operator-> () const |
| | Dereferences a member of the owned object.
|
| pointer | get_pointer () const |
| | Returns a pointer to the owned object.
|
| bool | unique () const |
| | Returns if this shared_ptr is the only owner of the current object.
|
| count_type | use_count () const |
| | The use count.
|
| void | swap (shared_ptr &other) noexcept |
| | Swaps the shared_ptr.
|
| impl_type | std_ptr () const |
| | Returns the underlying std::shared_ptr object.
|
template<typename Other>
requires std::is_same_v<Deleter, fcppt::default_deleter> |
| | shared_ptr (fcppt::detail::make_shared_wrapper< Other > &&) |
template<typename Type, typename Deleter>
template<typename Other, typename Alloc>
| fcppt::shared_ptr< Type, Deleter >::shared_ptr |
( |
Other * | pointer, |
|
|
Alloc const & | allocator ) |
Constructs a shared_ptr from a compatible pointer type and allocator.
Contructs a shared_ptr from pointer, taking ownership over it, also using allocator to manage the reference counts.
- Template Parameters
-
| Other | A type, so that Other * is implicitly convertible to Type * |
| Alloc | An allocator type |
- Parameters
-
| pointer | The pointer to take ownership of |
| allocator | The allocator to use for reference counting |
template<typename Type, typename Deleter>
template<typename Other>
Assigns a shared_ptr from a compatible shared_ptr.
Assigns this shared_ptr from ref. In any case, the reference count of the current shared_ptr will be decreased by one, possibly leading to the destruction of the object. If ref is empty, then this shared_ptr will also be empty. Otherwise, the shared count of ref will be increased by one and this shared_ptr will also take ownership.
- Template Parameters
-
| Other | A type, so that Other * is implicitly convertible to Type * |
- Parameters
-
template<typename Type, typename Deleter>
template<typename Other>
Assigns a shared_ptr from a compatible unique_ptr.
Assigns this shared_ptr from ref. In any case, the reference count of the current shared_ptr will be decreased by one, possibly leading to the destruction of the object. If ref is empty, then this shared_ptr will also be empty. Otherwise, this shared_ptr will take onwerhsip of the pointer from ref.
- Template Parameters
-
| Other | A type, so that Other * is implicitly convertible to T * |
- Parameters
-