17 static_assert(
sizeof(T) > 0,
"T must be a complete type");
18 static constexpr auto align_val =
alignof(T) - 1;
22 using pointer_type = T*;
24 static constexpr auto size =
sizeof(T);
25 static constexpr auto alignment =
alignof(T);
27 pointer_type get()
const noexcept {
28 if (ptr && ptr->is_init) {
29 std::byte* mem = ptr->memory;
30 uintptr_t align_up = -
reinterpret_cast<intptr_t
>(mem) & align_val;
31 return std::launder(
reinterpret_cast<pointer_type
>(mem + align_up));
36 value_type& operator*()
const noexcept {
40 pointer_type operator->()
const noexcept {
44 explicit operator bool()
const noexcept {
45 return static_cast<bool>(get());
50 std::byte memory[size + align_val];