sandbox
Loading...
Searching...
No Matches
aligned_storage.hpp
1#ifndef LIBSBX_MEMORY_ALIGNED_STORAGE_HPP_
2#define LIBSBX_MEMORY_ALIGNED_STORAGE_HPP_
3
4#include <memory>
5#include <type_traits>
6#include <cinttypes>
7
8namespace sbx::memory {
9
10template<std::size_t Size, std::size_t Alignment>
12 struct type {
13 alignas(Alignment) std::byte data[Size];
14 }; // union type
15}; // struct aligned_storage
16
17template<std::size_t Size, std::size_t Alignment>
18using aligned_storage_t = typename aligned_storage<Size, Alignment>::type;
19
20template<typename Type>
22 using type = alignas(alignof(Type)) std::byte[sizeof(Type)];
23}; // struct storage_for
24
25template<typename Type>
26using storage_for_t = typename storage_for<Type>::type;
27
28} // namespace sbx::memory
29
30#endif // LIBSBX_MEMORY_ALIGNED_STORAGE_HPP_
Definition: aligned_storage.hpp:12
Definition: aligned_storage.hpp:11
Definition: aligned_storage.hpp:21