|
Celeritas 0.7.0-dev.313+develop.1857205b
|
Clear and finalize default values when moving and destroying. More...
#include <InitializedValue.hh>
Public Member Functions | |
Constructors | |
| InitializedValue ()=default | |
| Construct implicitly with default value. | |
| InitializedValue (T const &value) | |
| Implicit construct from lvalue. | |
| InitializedValue (T &&value) | |
| Implicit construct from rvalue. | |
| InitializedValue (InitializedValue const &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default | |
| Default copy constructor. | |
| InitializedValue (InitializedValue &&other) noexcept(std::is_nothrow_move_constructible_v< T >) | |
| Exchange with other value on move construct. | |
| ~InitializedValue () noexcept(noexcept_finalize_) | |
| Call finalizer on destruct. | |
Assignment | |
| InitializedValue & | operator= (InitializedValue const &other) noexcept(noexcept_finalize_ &&std::is_nothrow_copy_assignable_v< T >) |
| Finalize our value when assigning. | |
| InitializedValue & | operator= (InitializedValue &&other) noexcept(noexcept_finalize_ &&std::is_nothrow_move_assignable_v< T >) |
| Clear other value on move assign. | |
Conversion | |
| operator T const & () const noexcept | |
| Implicit reference to stored value. | |
| operator T& () noexcept | |
| Implicit reference to stored value. | |
| T const & | value () const & |
| Explicit reference to stored value. | |
| T & | value () & |
| Implicit reference to stored value. | |
Clear and finalize default values when moving and destroying.
This helper class is used to simplify the "rule of 5" for classes that have to treat one member data specially but can use default assign/construct for the other elements. The default behavior is just to default-initialize when assigning and clearing the RHS when moving; this is useful for handling managed memory. The finalizer is called every time a non-default value is lost by assignment or destruction.