std::aligned_storage_t was deprecated in C++23, to be prepared for it,
let's use alignas for the same behavior. because the size of `Base`
class is not always power-of-2, while `alignas()` requires an alignment
of power of 2. so we use `std::bit_ceil()` to calculate the minimum
alignment greater or equal to its size.
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
#pragma once
+#include <bit>
#include <cstddef>
#include <utility>
#include <type_traits>
// difference in semantics between a pointer-to-const and a const
// pointer.
//
- mutable typename std::aligned_storage<Size>::type buf;
+ mutable struct alignas(std::bit_ceil(Size)) {
+ unsigned char data[sizeof(Base)];
+ } buf;
public:
using element_type = Base;