34#ifndef _UTILS_UNINITIALIZED_HXX_
35#define _UTILS_UNINITIALIZED_HXX_
98 constexpr const T*
get()
const
104 template <
class... Args> T &
emplace(Args &&... args)
106 new (
this) T(std::forward<Args>(args)...);
119 return static_cast<T *
>((
void*)&parent->data);
123 typename std::aligned_storage<
sizeof(T),
alignof(T)>::type data;
128 return static_cast<T *
>((
void*)&data);
131 constexpr const T *
tptr()
const
133 return static_cast<const T *
>((
void*)&data);
Template class that allows allocating storage for an object but not calling its constructor.
constexpr const T * tptr() const
const T & operator*() const
const T * operator->() const
void reset()
Destructs the embedded object.
constexpr T * get_mutable() const
Gets the embedded object pointer in a way that is friendly to linker-initialization.
static constexpr T * cast_data(uninitialized< T > *parent)
Public API to convert the pointer in a linker-initialized way.
constexpr T * tptrm() const
constexpr const T * get() const
Gets the embedded object pointer in a way that is friendly to linker-initialization.
T & emplace(Args &&... args)
Constructs the embedded object.