]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
neorados: avoid using std::aligned_storage_t
authorKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 08:52:59 +0000 (16:52 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 08:56:33 +0000 (16:56 +0800)
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 <tchaikov@gmail.com>
src/include/neorados/RADOS.hpp

index ab10e61858101c98ab2076db15bb6122345e87c4..27ca79f1a0d1e6f00edfd527092a1758edc786b0 100644 (file)
@@ -78,6 +78,10 @@ struct hash<neorados::IOContext>;
 namespace neorados {
 namespace detail {
 class Client;
+template<std::size_t S, std::size_t Alignment = std::bit_ceil(S)>
+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_size> impl;
+  detail::aligned_storage<impl_size> 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_size> impl;
+  detail::aligned_storage<impl_size> 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_size> impl;
+  detail::aligned_storage<impl_size> 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_size> impl;
+  detail::aligned_storage<impl_size> impl;
 };
 
 // Result from `next_notification`