Skip to content

Commit

Permalink
Merge pull request #284 from black-sat/fix/aligned_storage
Browse files Browse the repository at this point in the history
Remove usage of `std::aligned_storage` to switch off deprecation warnings in C++23
  • Loading branch information
arximboldi authored May 1, 2024
2 parents 00cdcbf + 69efb28 commit bd9f318
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion immer/detail/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,20 @@ const T& as_const(T& x)
return x;
}

template<std::size_t Size, std::size_t Align>
struct aligned_storage
{
struct type {
alignas(Align) unsigned char data[Size];
};
};

template<std::size_t Size, std::size_t Align>
using aligned_storage_t = typename aligned_storage<Size, Align>::type;

template <typename T>
using aligned_storage_for =
typename std::aligned_storage<sizeof(T), alignof(T)>::type;
typename aligned_storage<sizeof(T), alignof(T)>::type;

template <typename T>
T& auto_const_cast(const T& x)
Expand Down
6 changes: 5 additions & 1 deletion immer/heap/debug_size_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <immer/config.hpp>
#include <immer/heap/identity_heap.hpp>
#include <immer/detail/util.hpp>

#include <cassert>
#include <cstddef>
Expand Down Expand Up @@ -39,7 +40,10 @@ struct debug_size_heap
constexpr static auto extra_size = 8;
#else
constexpr static auto extra_size = sizeof(
std::aligned_storage_t<sizeof(std::size_t), alignof(std::max_align_t)>);
detail::aligned_storage_t<
sizeof(std::size_t), alignof(std::max_align_t)
>
);
#endif

template <typename... Tags>
Expand Down

0 comments on commit bd9f318

Please sign in to comment.