From a733b58cd2a9d90b73f182a6277ce6cc6425a4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 10 May 2022 00:07:22 +0200 Subject: [PATCH] Replace C++23-deprecated aligned_storage_t --- src/catch2/benchmark/catch_constructor.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/catch2/benchmark/catch_constructor.hpp b/src/catch2/benchmark/catch_constructor.hpp index 3e2b87e5..1effad56 100644 --- a/src/catch2/benchmark/catch_constructor.hpp +++ b/src/catch2/benchmark/catch_constructor.hpp @@ -20,9 +20,7 @@ namespace Catch { template struct ObjectStorage { - using TStorage = std::aligned_storage_t::value>; - - ObjectStorage() : data() {} + ObjectStorage() = default; ObjectStorage(const ObjectStorage& other) { @@ -31,7 +29,7 @@ namespace Catch { ObjectStorage(ObjectStorage&& other) { - new(&data) T(CATCH_MOVE(other.stored_object())); + new(data) T(CATCH_MOVE(other.stored_object())); } ~ObjectStorage() { destruct_on_exit(); } @@ -39,7 +37,7 @@ namespace Catch { template void construct(Args&&... args) { - new (&data) T(CATCH_FORWARD(args)...); + new (data) T(CATCH_FORWARD(args)...); } template @@ -57,15 +55,15 @@ namespace Catch { void destruct_on_exit(std::enable_if_t* = nullptr) { } T& stored_object() { - return *static_cast(static_cast(&data)); + return *static_cast(static_cast(data)); } T const& stored_object() const { - return *static_cast(static_cast(&data)); + return *static_cast(static_cast(data)); } - TStorage data; + alignas( T ) unsigned char data[sizeof( T )]{}; }; } // namespace Detail