From a17b768c5f5124f3ec20f113ef72168e2dbf0ed5 Mon Sep 17 00:00:00 2001 From: Nicola Gigante Date: Sun, 28 Apr 2024 18:28:26 +0200 Subject: [PATCH 1/3] Remove usage of `std::aligned_storage` --- immer/detail/util.hpp | 13 ++++++++++++- immer/heap/debug_size_heap.hpp | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/immer/detail/util.hpp b/immer/detail/util.hpp index d6ae246b..b68b9d1a 100644 --- a/immer/detail/util.hpp +++ b/immer/detail/util.hpp @@ -36,9 +36,20 @@ const T& as_const(T& x) return x; } +template +struct aligned_storage +{ + struct type { + alignas(Align) unsigned char data[Size] = { }; + }; +}; + +template +using aligned_storage_t = typename aligned_storage::type; + template using aligned_storage_for = - typename std::aligned_storage::type; + typename aligned_storage::type; template T& auto_const_cast(const T& x) diff --git a/immer/heap/debug_size_heap.hpp b/immer/heap/debug_size_heap.hpp index d5288c64..d55ed5be 100644 --- a/immer/heap/debug_size_heap.hpp +++ b/immer/heap/debug_size_heap.hpp @@ -39,7 +39,10 @@ struct debug_size_heap constexpr static auto extra_size = 8; #else constexpr static auto extra_size = sizeof( - std::aligned_storage_t); + detail::aligned_storage_t< + sizeof(std::size_t), alignof(std::max_align_t) + > + ); #endif template From 2f9dede179f9cc802a9750e523a8d251acae723a Mon Sep 17 00:00:00 2001 From: Nicola Gigante Date: Sun, 28 Apr 2024 21:32:48 +0200 Subject: [PATCH 2/3] Make `details::aligned_storage` trivially constructible --- immer/detail/util.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/immer/detail/util.hpp b/immer/detail/util.hpp index b68b9d1a..f1af9d03 100644 --- a/immer/detail/util.hpp +++ b/immer/detail/util.hpp @@ -40,7 +40,7 @@ template struct aligned_storage { struct type { - alignas(Align) unsigned char data[Size] = { }; + alignas(Align) unsigned char data[Size]; }; }; From 69efb28c54a86e9239d7dc095df7bb53ccce0a40 Mon Sep 17 00:00:00 2001 From: Nicola Gigante Date: Sun, 28 Apr 2024 21:36:10 +0200 Subject: [PATCH 3/3] Include util.hpp --- immer/heap/debug_size_heap.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/immer/heap/debug_size_heap.hpp b/immer/heap/debug_size_heap.hpp index d55ed5be..4c5884b0 100644 --- a/immer/heap/debug_size_heap.hpp +++ b/immer/heap/debug_size_heap.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include