Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-10 00:07:22 +0200
committerMartin Hořeňovský2022-05-10 00:07:22 +0200
commita733b58cd2a9d90b73f182a6277ce6cc6425a4c3 (patch)
tree296ce02727f2353d1327ca583434eda57f7a605e /src
parentd9b0a38f81df4bd5876888ba7937f5750b59b5a5 (diff)
downloadcatch3-a733b58cd2a9d90b73f182a6277ce6cc6425a4c3.tar.gz
Replace C++23-deprecated aligned_storage_t
Diffstat (limited to 'src')
-rw-r--r--src/catch2/benchmark/catch_constructor.hpp14
1 files 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 <typename T, bool Destruct>
struct ObjectStorage
{
- using TStorage = std::aligned_storage_t<sizeof(T), std::alignment_of<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<T>(); }
@@ -39,7 +37,7 @@ namespace Catch {
template <typename... Args>
void construct(Args&&... args)
{
- new (&data) T(CATCH_FORWARD(args)...);
+ new (data) T(CATCH_FORWARD(args)...);
}
template <bool AllowManualDestruction = !Destruct>
@@ -57,15 +55,15 @@ namespace Catch {
void destruct_on_exit(std::enable_if_t<!Destruct, U>* = nullptr) { }
T& stored_object() {
- return *static_cast<T*>(static_cast<void*>(&data));
+ return *static_cast<T*>(static_cast<void*>(data));
}
T const& stored_object() const {
- return *static_cast<T*>(static_cast<void*>(&data));
+ return *static_cast<T*>(static_cast<void*>(data));
}
- TStorage data;
+ alignas( T ) unsigned char data[sizeof( T )]{};
};
} // namespace Detail