Просмотр исходного кода

any: avoid declaring nested types in an union

Michele Caini 3 лет назад
Родитель
Сommit
871234ec76
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      src/entt/core/any.hpp

+ 5 - 3
src/entt/core/any.hpp

@@ -54,6 +54,10 @@ class basic_any {
     using policy = internal::any_policy;
     using policy = internal::any_policy;
     using vtable_type = const void *(const operation, const basic_any &, const void *);
     using vtable_type = const void *(const operation, const basic_any &, const void *);
 
 
+    struct storage_type {
+        alignas(Align) std::byte data[Len + !Len];
+    };
+
     template<typename Type>
     template<typename Type>
     static constexpr bool in_situ = Len && alignof(Type) <= Align && sizeof(Type) <= Len &&std::is_nothrow_move_constructible_v<Type>;
     static constexpr bool in_situ = Len && alignof(Type) <= Align && sizeof(Type) <= Len &&std::is_nothrow_move_constructible_v<Type>;
 
 
@@ -407,9 +411,7 @@ public:
 private:
 private:
     union {
     union {
         const void *instance;
         const void *instance;
-        struct storage_type {
-            alignas(Align) std::byte data[Len + !Len];
-        } storage;
+        storage_type storage;
     };
     };
     const type_info *info;
     const type_info *info;
     vtable_type *vtable;
     vtable_type *vtable;