|
Open Model Railroad Network (OpenMRN)
|
Template class that allows allocating storage for an object but not calling its constructor. More...
#include <Uninitialized.hxx>
Public Member Functions | |
| const T * | operator-> () const |
| T * | operator-> () |
| T & | operator* () |
| const T & | operator* () const |
| T & | value () |
| const T & | value () const |
| constexpr T * | get_mutable () const |
| Gets the embedded object pointer in a way that is friendly to linker-initialization. | |
| constexpr const T * | get () const |
| Gets the embedded object pointer in a way that is friendly to linker-initialization. | |
| template<class... Args> | |
| T & | emplace (Args &&... args) |
| Constructs the embedded object. | |
| void | reset () |
| Destructs the embedded object. | |
Static Public Member Functions | |
| static constexpr T * | cast_data (uninitialized< T > *parent) |
| Public API to convert the pointer in a linker-initialized way. | |
Private Member Functions | |
| constexpr T * | tptrm () const |
| constexpr const T * | tptr () const |
Private Attributes | |
| std::aligned_storage< sizeof(T), alignof(T)>::type | data |
Template class that allows allocating storage for an object but not calling its constructor.
The object shall be constructed before first use by calling emplace(). It is the responsibility of the caller to also call the destructor sometime by invoking reset(), otherwise the object will be leaked.
Using this class is inherently unsafe, so avoid if possible. After c++17 this class will be replaceable by std::optional.
Definition at line 49 of file Uninitialized.hxx.
|
inlinestaticconstexpr |
Public API to convert the pointer in a linker-initialized way.
Definition at line 117 of file Uninitialized.hxx.
|
inline |
Constructs the embedded object.
Definition at line 104 of file Uninitialized.hxx.
|
inlineconstexpr |
Gets the embedded object pointer in a way that is friendly to linker-initialization.
NOTE: when switching to std::optional<>, calls to this function need to be replaced with calls to .operator->().
Definition at line 98 of file Uninitialized.hxx.
|
inlineconstexpr |
Gets the embedded object pointer in a way that is friendly to linker-initialization.
NOTE: when switching to std::optional<>, calls to this function need to be replaced with calls to .operator->().
Definition at line 88 of file Uninitialized.hxx.
|
inline |
Definition at line 63 of file Uninitialized.hxx.
|
inline |
Definition at line 68 of file Uninitialized.hxx.
|
inline |
Definition at line 58 of file Uninitialized.hxx.
|
inline |
Definition at line 53 of file Uninitialized.hxx.
|
inline |
Destructs the embedded object.
Definition at line 111 of file Uninitialized.hxx.
|
inlineconstexprprivate |
Definition at line 131 of file Uninitialized.hxx.
|
inlineconstexprprivate |
Definition at line 126 of file Uninitialized.hxx.
|
inline |
Definition at line 73 of file Uninitialized.hxx.
|
inline |
Definition at line 78 of file Uninitialized.hxx.
|
private |
Definition at line 123 of file Uninitialized.hxx.