From 95e71b10b02e2d5cfe41b5d9f8dd6a01382cf981 Mon Sep 17 00:00:00 2001 From: attila Date: Wed, 10 Jul 2024 19:25:36 +0200 Subject: [PATCH] FixedSizeFunction: Replace std::aligned_storage_t to avoid C++23 warning We are ignoring warning 4324, which warns us that a FixedSizeFunction<4> will have it's size increased to 8 bytes, due to the minimum alignment requirement of 8 bytes. --- modules/juce_core/containers/juce_FixedSizeFunction.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/juce_core/containers/juce_FixedSizeFunction.h b/modules/juce_core/containers/juce_FixedSizeFunction.h index 1eedf720df..2d185ee9e5 100644 --- a/modules/juce_core/containers/juce_FixedSizeFunction.h +++ b/modules/juce_core/containers/juce_FixedSizeFunction.h @@ -108,14 +108,12 @@ template class FixedSizeFunction { private: - using Storage = std::aligned_storage_t; - template using Decay = std::decay_t; template > using IntIfValidConversion = std::enable_if_t, int>; @@ -137,7 +135,7 @@ public: { static_assert (sizeof (Fn) <= len, "The requested function cannot fit in this FixedSizeFunction"); - static_assert (alignof (Fn) <= alignof (Storage), + static_assert (alignof (Fn) <= alignof (std::max_align_t), "FixedSizeFunction cannot accommodate the requested alignment requirements"); static constexpr auto vtableForCallable = detail::makeVtable(); @@ -228,7 +226,10 @@ private: } const detail::Vtable* vtable = nullptr; - mutable Storage storage; + + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4324) + alignas (std::max_align_t) mutable std::byte storage[len]; + JUCE_END_IGNORE_WARNINGS_MSVC }; template