Celeritas  0.5.0-56+6b053cd
List of all members
celeritas::InitializedValue< T, Finalizer > Class Template Reference

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.
 
Assignment
InitializedValueoperator= (InitializedValue const &other) noexcept(ne_finalize_ &&std::is_nothrow_copy_assignable_v< T >)
 Finalize our value when assigning.
 
InitializedValueoperator= (InitializedValue &&other) noexcept(ne_finalize_ &&std::is_nothrow_move_assignable_v< T >)
 Clear other value on move assign.
 
InitializedValueoperator= (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)
 

Detailed Description

template<class T, class Finalizer = detail::DefaultFinalize<T>>
class celeritas::InitializedValue< T, Finalizer >

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.

Member Function Documentation

◆ finalizer() [1/2]

template<class T , class Finalizer = detail::DefaultFinalize<T>>
Finalizer const& celeritas::InitializedValue< T, Finalizer >::finalizer ( ) const
inline

Access finalizer

◆ finalizer() [2/2]

template<class T , class Finalizer = detail::DefaultFinalize<T>>
void celeritas::InitializedValue< T, Finalizer >::finalizer ( Finalizer  fin)
inline

Access finalizer


The documentation for this class was generated from the following file: