1#ifndef LIBSBX_MEMORY_ALIGNED_STORAGE_HPP_
2#define LIBSBX_MEMORY_ALIGNED_STORAGE_HPP_
10template<std::
size_t Size, std::
size_t Alignment>
13 alignas(Alignment) std::byte data[Size];
17template<std::
size_t Size, std::
size_t Alignment>
20template<
typename Type>
23 struct alignas(alignof(Type))
type {
24 std::byte data[
sizeof(Type)];
28template<
typename Type>
39template<
typename Type>
44 using value_type = Type;
56 template<
typename... Args>
57 requires (std::is_constructible_v<Type, Args...>)
58 auto construct(Args&&... args) -> Type* {
59 return std::construct_at(_ptr(), std::forward<Args>(args)...);
62 auto destroy()
noexcept ->
void {
63 std::destroy_at(_ptr());
66 auto get()
noexcept -> Type* {
70 auto get()
const noexcept ->
const Type* {
74 auto operator*()
noexcept -> Type& {
78 auto operator*()
const noexcept ->
const Type& {
84 auto _ptr()
noexcept -> Type* {
85 return std::launder(
reinterpret_cast<Type*
>(&_storage));
88 auto _ptr()
const noexcept ->
const Type* {
89 return std::launder(
reinterpret_cast<const Type*
>(&_storage));
92 storage_for_t<Type> _storage;
A class that allows for the manual construction and destruction of an object of type Type.
Definition: aligned_storage.hpp:40
Definition: aligned_storage.hpp:12
Definition: aligned_storage.hpp:11
Definition: aligned_storage.hpp:23
Definition: aligned_storage.hpp:21