From 871234ec76e9b4f5819ea008697fa66b6f2c9cd8 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 6 Sep 2022 23:41:45 +0200 Subject: [PATCH] any: avoid declaring nested types in an union --- src/entt/core/any.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index e7f800399..69b877ab2 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -54,6 +54,10 @@ class basic_any { using policy = internal::any_policy; using vtable_type = const void *(const operation, const basic_any &, const void *); + struct storage_type { + alignas(Align) std::byte data[Len + !Len]; + }; + template static constexpr bool in_situ = Len && alignof(Type) <= Align && sizeof(Type) <= Len &&std::is_nothrow_move_constructible_v; @@ -407,9 +411,7 @@ public: private: union { const void *instance; - struct storage_type { - alignas(Align) std::byte data[Len + !Len]; - } storage; + storage_type storage; }; const type_info *info; vtable_type *vtable;