The Owner<T> class template represents ownership of an object pointer. It indicates that the pointed object must either be transferred to another owner (like another Owner, or a std::unique_ptr) or deleted. Owner provides exception safety to classes and functions that handle objects with dynamic lifetime, by guaranteeing deletion of the pointed object on both normal exit or exit through exception.
More...
|
| | Owner () noexcept |
| | Construct an empty Owner. More...
|
| |
| template<typename P , typename = if_compliant_and_convertible_from<P>> |
| | Owner (P *p) noexcept |
| | Construct an Owner that owns the object pointed by p. The owned object will be destructed using the expression delete p. The pointer p used for deletion is captured at the construction time of the Owner. More...
|
| |
| template<typename P , typename = if_compliant_and_convertible_from<P>> |
| | Owner (P *p, DeleterFunc< P > d) noexcept |
| | Construct an Owner that owns the object pointed by p, with a custom pointer deleter set to d. The owned object will be destructed using the expression d(p). The deleter (if any) is invoked in all cases, even when the object pointer p is null. The pointer p used for deletion is captured at the construction time of the Owner. More...
|
| |
| | ~Owner () noexcept=default |
| | Destruct this Owner. If no custom deleter was provided, the owned object is disposed using a delete p expression, otherwise the owned object is disposed using a d(p) expression. More...
|
| |
| | Owner (Owner &&rhs) noexcept=default |
| | Move constructor. More...
|
| |
| template<typename P , typename = if_convertible_from<P>> |
| | Owner (Owner< P > &&rhs) noexcept |
| | Move conversion This move conversion is only considered if a P* can be implicitly converted to a T*. More...
|
| |
| Owner & | operator= (Owner &&rhs) noexcept=default |
| | Move assignment operator Move assign the Owner rhs to *this. More...
|
| |
| constexpr | operator bool () const noexcept |
| | Check if the wrapped pointer is null. More...
|
| |
| const T & | operator* () const noexcept |
| | Indirection operator. More...
|
| |
| T & | operator* () noexcept |
| | Indirection operator. More...
|
| |
| const T * | operator-> () const noexcept |
| | Indirection operator. More...
|
| |
| T * | operator-> () noexcept |
| | Indirection operator. More...
|
| |
| const T * | get () const noexcept |
| | Accessor. More...
|
| |
| T * | get () noexcept |
| | Accessor. More...
|
| |
| Owner & | reset () noexcept |
| | Reset this Owner object to its uninitialized state, deleting the currently owned object (if any). More...
|
| |
| void | swap (Owner &other) noexcept |
| | Swap the content of this Owner with another one. More...
|
| |
template<typename T>
class BifrostGraph::Executor::Owner< T >
The Owner<T> class template represents ownership of an object pointer. It indicates that the pointed object must either be transferred to another owner (like another Owner, or a std::unique_ptr) or deleted. Owner provides exception safety to classes and functions that handle objects with dynamic lifetime, by guaranteeing deletion of the pointed object on both normal exit or exit through exception.
- Template Parameters
-
| T | the owned object's exposed type used by indirection operators and by accessors. |
Definition at line 38 of file Owner.h.
template<typename T >
template<typename P , typename = if_compliant_and_convertible_from<P>>
Construct an Owner that owns the object pointed by p. The owned object will be destructed using the expression delete p. The pointer p used for deletion is captured at the construction time of the Owner.
This constructor is only considered if a P* can be implicitly converted to a T*.
If an error occurs while initializing the new Owner, the object pointed by p is deleted before returning control to the caller and the resulting Owner will be empty.
- Postcondition
get() == p if the initialization of the new Owner succeeded; get() == nullptr otherwise.
- Template Parameters
-
| P | the storage type used for the owned object. |
- Parameters
-
| [in] | p | a pointer to an object to be owned by the Owner or a null pointer. |
Definition at line 87 of file Owner.h.
template<typename T >
template<typename P , typename = if_compliant_and_convertible_from<P>>
Construct an Owner that owns the object pointed by p, with a custom pointer deleter set to d. The owned object will be destructed using the expression d(p). The deleter (if any) is invoked in all cases, even when the object pointer p is null. The pointer p used for deletion is captured at the construction time of the Owner.
This constructor is only considered if a P* can be implicitly converted to a T*.
If an error occurs while initializing the new Owner and the custom deleter is valid, the object pointed by p is deleted using the custom deleter before returning control to the caller; if the custom deleter is invalid (nullptr), the object pointed by p is not deleted before returning control to the caller. In all error cases, the resulting Owner will be empty.
- Precondition
- the custom pointer deleter must not be null
- Postcondition
get() == p if the initialization of the new Owner succeeded; get() == nullptr otherwise.
- Template Parameters
-
| P | the storage type used for the owned object. |
- Parameters
-
| [in] | p | a pointer to an object to be owned by the Owner or a null pointer. |
| [in] | d | the deleter to invoke when this Owner is destructed. |
Definition at line 120 of file Owner.h.