|
ACTS
Experiment-independent tracking
|
A copyable smart pointer that uses a cloner function to copy the managed object. More...
#include <Acts/Utilities/CloneablePtr.hpp>
Public Types | |
| using | Cloner = std::function<std::unique_ptr<T>(const T&)> |
| The type of the cloner function. | |
| using | element_type = T |
| Define the type of the managed object. | |
Public Member Functions | |
| CloneablePtr ()=default | |
| Default constructor, creates a null pointer. | |
| CloneablePtr (CloneablePtr &&) noexcept=default | |
| Move constructor. | |
| CloneablePtr (const CloneablePtr &other) | |
| Copy constructor. | |
| CloneablePtr (std::unique_ptr< T > ptr) | |
| Construct from a unique_ptr using copy construction as the cloner. | |
| CloneablePtr (std::unique_ptr< T > ptr, Cloner cloner) | |
| Construct from a unique_ptr with a custom cloner. | |
| CloneablePtr (T *raw) | |
| Construct by taking ownership of a raw pointer using copy construction as the cloner. | |
| CloneablePtr (T *raw, Cloner cloner) | |
| Construct by taking ownership of a raw pointer with a custom cloner. | |
| ~CloneablePtr ()=default | |
| Destructor. | |
| T * | get () const |
| Get the raw pointer. | |
| operator bool () const | |
| Boolean conversion, true if non-null. | |
| T & | operator* () const |
| Dereference operator. | |
| T * | operator-> () const |
| Arrow operator. | |
| CloneablePtr & | operator= (CloneablePtr &&) noexcept=default |
| Move assignment. | |
| CloneablePtr & | operator= (const CloneablePtr &other) noexcept |
| Copy assignment. | |
| template<typename T1> requires (std::is_copy_constructible_v<T1> && std::is_base_of_v<T, T1>) | |
| CloneablePtr & | operator= (std::unique_ptr< T1 > &&ptr) noexcept |
| Move assignment from a unique_ptr. | |
| std::unique_ptr< T > | release () |
| Release ownership of the managed object. | |
| void | reset (T *ptr=nullptr) |
| Reset the managed object. | |
A copyable smart pointer that uses a cloner function to copy the managed object.
This enables polymorphic value semantics: you can copy a pointer to a base class by invoking a stored cloner function (typically calling a virtual clone() method or a copy constructor).
| T | The type of the managed object |
| Acts::CloneablePtr< T >::CloneablePtr | ( | std::unique_ptr< T > | ptr, |
| Cloner | cloner ) |
Construct from a unique_ptr with a custom cloner.
| ptr | The unique_ptr to take ownership of |
| cloner | The cloner function |
|
explicit |
Construct from a unique_ptr using copy construction as the cloner.
| ptr | The unique_ptr to take ownership of |
| Acts::CloneablePtr< T >::CloneablePtr | ( | T * | raw, |
| Cloner | cloner ) |
Construct by taking ownership of a raw pointer with a custom cloner.
| raw | The raw pointer to take ownership of |
| cloner | The cloner function |
|
explicit |
Construct by taking ownership of a raw pointer using copy construction as the cloner.
| raw | The raw pointer to take ownership of |
| Acts::CloneablePtr< T >::CloneablePtr | ( | const CloneablePtr< T > & | other | ) |
Copy constructor.
Invokes the cloner if the source is non-null.
| other | The CloneablePtr to copy from |
| T * Acts::CloneablePtr< T >::get | ( | ) | const |
Get the raw pointer.
| T & Acts::CloneablePtr< T >::operator* | ( | ) | const |
Dereference operator.
| T * Acts::CloneablePtr< T >::operator-> | ( | ) | const |
Arrow operator.
|
defaultnoexcept |
Move assignment.
|
noexcept |
Copy assignment.
Invokes the cloner if the source is non-null.
| other | The CloneablePtr to copy from |
|
noexcept |
Move assignment from a unique_ptr.
| ptr | The unique_ptr that's assigned to this object |
| std::unique_ptr< T > Acts::CloneablePtr< T >::release | ( | ) |
Release ownership of the managed object.
| void Acts::CloneablePtr< T >::reset | ( | T * | ptr = nullptr | ) |
Reset the managed object.
| ptr | The new raw pointer to manage (default nullptr) |