diff options
Diffstat (limited to 'pw_alignment/public/pw_alignment/alignment.h')
-rw-r--r-- | pw_alignment/public/pw_alignment/alignment.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/pw_alignment/public/pw_alignment/alignment.h b/pw_alignment/public/pw_alignment/alignment.h index e295c5d0c..7c173bdb0 100644 --- a/pw_alignment/public/pw_alignment/alignment.h +++ b/pw_alignment/public/pw_alignment/alignment.h @@ -56,14 +56,15 @@ constexpr size_t bit_ceil(size_t x) noexcept { // The NaturallyAligned class is a wrapper class for ensuring the object is // aligned to a power of 2 bytes greater than or equal to its size. template <typename T> -struct [[gnu::aligned(bit_ceil(sizeof(T)))]] NaturallyAligned - : public T{NaturallyAligned() : T(){} NaturallyAligned(const T& t) : - T(t){} template <class U> - NaturallyAligned(const U& u) : T(u){} NaturallyAligned - operator=(T other){return T::operator=(other); -} // namespace pw -} -; +struct [[gnu::aligned(bit_ceil(sizeof(T)))]] NaturallyAligned : public T { + NaturallyAligned() : T() {} + NaturallyAligned(const T& t) : T(t) {} + template <class U> + NaturallyAligned(const U& u) : T(u) {} + NaturallyAligned operator=(T other) { + return T::operator=(other); + } // namespace pw +}; // This is a convenience wrapper for ensuring the object held by std::atomic is // naturally aligned. Ensuring the underlying objects's alignment is natural |