Owning pointer wrapper with move only value semantics. Usefull for implementing the pointer to implementation (PIMPL) pattern.
More...
|
|
| Pimpl (std::nullptr_t)=delete |
| | Deleted constructor to prevent construction from nullptr.
|
| | Pimpl (StorageType impl) |
| | Construct Pimpl from a pointer to the object.
|
| template<typename T, typename... Args> |
| | Pimpl (std::in_place_type_t< T >, Args &&... args) |
| | Construct the wrapped object in place.
|
|
| ~Pimpl ()=default |
| | Default destructor.
|
|
| Pimpl (const Pimpl &)=delete |
| | Pimpl is not copyable.
|
|
Pimpl & | operator= (const Pimpl &)=delete |
| | Pimpl is not copyable.
|
|
| Pimpl (Pimpl &&)=default |
| | Default move constructor.
|
|
Pimpl & | operator= (Pimpl &&)=default |
| | Default move assignment operator.
|
| Interface & | operator* () noexcept |
| | Dereference operator for non-const access.
|
| const Interface & | operator* () const noexcept |
| | Dereference operator for const access.
|
| Interface * | operator-> () noexcept |
| | Arrow operator for non-const access.
|
| const Interface * | operator-> () const noexcept |
| | Arrow operator for const access.
|
| bool | valueless_after_move () const noexcept |
| | Checks if the object is in moved from state.
|
template<typename Interface, typename StorageType = std::unique_ptr<Interface>>
class mrs_lib::Pimpl< Interface, StorageType >
Owning pointer wrapper with move only value semantics. Usefull for implementing the pointer to implementation (PIMPL) pattern.
- Template Parameters
-
| Interface | The interface / class type that the Pimpl will hold. |
| StorageType | The type of value used to store for the implementation (defaults to std::unique_ptr<Interface>). |
Contains the specified value using the StorageType. Compared to std::*_ptr, this class uses deep const semantics and is not nullable (with the exception of the moved from state in which it should not be used).
When implementing the PIMPL pattern for your own classes, the default pointer type should be correct.
This class can also be used to wrap non nullable ros interfaces (eg. rclcpp::Publisher), which are provided as std::shared_ptr. In those cases you can set StorageType to std::shared_ptr (eg. for the publisher: mrs_lib::Pimpl<rclcpp::Publisher, std::shared_ptr<rclcpp::Publisher>>). The class will keep the same semantics, but will use different storage.