25 #ifndef APPLICATIONS_STORAGE_STORAGE_COMMON_ALIGNED_NEW_HPP_
26 #define APPLICATIONS_STORAGE_STORAGE_COMMON_ALIGNED_NEW_HPP_
32 #include <type_traits>
42 throw std::logic_error{
43 "Specified alignment must be at least the natural alignment of the object"};
47 throw std::logic_error{
48 "Specified alignment must be a multiple the natural alignment of the object"};
51 m_alignment = alignment;
62 template <
typename... Args>
67 throw std::bad_alloc{};
71 static_cast<void>(
new (
storage) T{std::forward<Args>(args)...});
87 template <
typename... Args>
92 throw std::bad_alloc{};
95 size_t valid_count = 0;
97 for (
size_t ii = 0; ii != object_count; ++ii) {
98 static_cast<void>(
new (std::addressof(
storage[ii])) T{args...});
102 while (valid_count) {
make_aligned< T > & aligned_to(size_t alignment)
T * object_array(size_t object_count, Args &&...args) const
T * object(Args &&...args) const
void * aligned_alloc(size_t alignment, size_t size)