From ba7b42983cc6e1966f9149cc6160a4ae6154f9e0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 19 Jun 2025 16:52:59 +0800 Subject: [PATCH] neorados: avoid using std::aligned_storage_t std::aligned_storage_t was deprecated in C++23, to be prepared for it, let's use alignas for the same behavior. because we do not always pass a power-of-2 number to `std::aligned_storage_t`, while `alignas()` requires an alignment of power of 2. so we use `std::bit_ceil()` to calculate the minimum alignment greater or equal to the given number. Signed-off-by: Kefu Chai --- src/include/neorados/RADOS.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/include/neorados/RADOS.hpp b/src/include/neorados/RADOS.hpp index ab10e61858101..27ca79f1a0d1e 100644 --- a/src/include/neorados/RADOS.hpp +++ b/src/include/neorados/RADOS.hpp @@ -78,6 +78,10 @@ struct hash; namespace neorados { namespace detail { class Client; +template +struct alignas(Alignment) aligned_storage { + std::byte data[S]; +}; } class RADOS; @@ -117,7 +121,7 @@ public: private: static constexpr std::size_t impl_size = 4 * 8; - std::aligned_storage_t impl; + detail::aligned_storage impl; }; inline constexpr std::uint64_t snap_dir = -1; @@ -193,7 +197,7 @@ public: private: static constexpr std::size_t impl_size = 16 * 8; - std::aligned_storage_t impl; + detail::aligned_storage impl; }; inline const std::string all_nspaces("\001"); @@ -386,7 +390,7 @@ public: protected: Op(); static constexpr std::size_t impl_size = 85 * 8; - std::aligned_storage_t impl; + detail::aligned_storage impl; }; // This class is /not/ thread-safe. If you want you can wrap it in @@ -1278,7 +1282,7 @@ private: Cursor(void*); friend RADOS; static constexpr std::size_t impl_size = 16 * 8; - std::aligned_storage_t impl; + detail::aligned_storage impl; }; // Result from `next_notification` -- 2.39.5