Celeritas
0.5.0-86+4a8eea4
|
Clear the value of the object on initialization and moving. 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 const &value, Finalizer fin) | |
Implicit construct from lvalue and finalizer. | |
InitializedValue (T &&value) | |
Implicit construct from rvalue. | |
InitializedValue (T &&value, Finalizer fin) | |
Implicit construct from value type and finalizer. | |
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 >) | |
Clear other value on move construct. | |
~InitializedValue ()=default | |
Construct implicitly with default value. | |
Assignment | |
InitializedValue & | operator= (InitializedValue const &other) noexcept(ne_finalize_ &&std::is_nothrow_copy_assignable_v< T >) |
Finalize our value when assigning. | |
InitializedValue & | operator= (InitializedValue &&other) noexcept(ne_finalize_ &&std::is_nothrow_move_assignable_v< T >) |
Clear other value on move assign. | |
InitializedValue & | operator= (T const &value) noexcept(ne_finalize_ &&std::is_nothrow_copy_assignable_v< T >) |
Implicit assign from type. | |
void | swap (InitializedValue &other) noexcept |
Swap with another value. | |
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. | |
T && | value () && |
Implicit reference to stored value. | |
Finalizer const & | finalizer () const |
void | finalizer (Finalizer fin) |
Clear the value of the object on initialization and moving.
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 useful when the type has a destructor-type method that has to be called before clearing it.
|
inline |
Access finalizer
|
inline |
Access finalizer