Celeritas 0.7.0-dev.313+develop.1857205b
Loading...
Searching...
No Matches
List of all members
celeritas::InitializedValue< T, Finalizer > Class Template Reference

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
InitializedValueoperator= (InitializedValue const &other) noexcept(noexcept_finalize_ &&std::is_nothrow_copy_assignable_v< T >)
 Finalize our value when assigning.
 
InitializedValueoperator= (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 constvalue () const &
 Explicit reference to stored value.
 
Tvalue () &
 Implicit reference to stored value.
 

Detailed Description

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

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.


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