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

any/poly: avoid using aligned_storage_t (deprecated - close #919)

Michele Caini 3 лет назад
Родитель
Сommit
70b8bd27b8
3 измененных файлов с 6 добавлено и 9 удалено
  1. 2 3
      src/entt/core/any.hpp
  2. 2 3
      src/entt/core/fwd.hpp
  3. 2 3
      src/entt/poly/fwd.hpp

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

@@ -53,11 +53,10 @@ class basic_any {
     using operation = internal::any_operation;
     using operation = internal::any_operation;
     using policy = internal::any_policy;
     using policy = internal::any_policy;
 
 
-    using storage_type = std::aligned_storage_t<Len + !Len, Align>;
     using vtable_type = const void *(const operation, const basic_any &, const void *);
     using vtable_type = const void *(const operation, const basic_any &, const void *);
 
 
     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>;
 
 
     template<typename Type>
     template<typename Type>
     static const void *basic_vtable([[maybe_unused]] const operation op, [[maybe_unused]] const basic_any &value, [[maybe_unused]] const void *other) {
     static const void *basic_vtable([[maybe_unused]] const operation op, [[maybe_unused]] const basic_any &value, [[maybe_unused]] const void *other) {
@@ -409,7 +408,7 @@ public:
 private:
 private:
     union {
     union {
         const void *instance;
         const void *instance;
-        storage_type storage;
+        alignas(Align) std::byte storage[Len + !Len];
     };
     };
     const type_info *info;
     const type_info *info;
     vtable_type *vtable;
     vtable_type *vtable;

+ 2 - 3
src/entt/core/fwd.hpp

@@ -1,13 +1,12 @@
 #ifndef ENTT_CORE_FWD_HPP
 #ifndef ENTT_CORE_FWD_HPP
 #define ENTT_CORE_FWD_HPP
 #define ENTT_CORE_FWD_HPP
 
 
-#include <cstdint>
-#include <type_traits>
+#include <cstddef>
 #include "../config/config.h"
 #include "../config/config.h"
 
 
 namespace entt {
 namespace entt {
 
 
-template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(typename std::aligned_storage_t<Len + !Len>)>
+template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
 class basic_any;
 class basic_any;
 
 
 /*! @brief Alias declaration for type identifiers. */
 /*! @brief Alias declaration for type identifiers. */

+ 2 - 3
src/entt/poly/fwd.hpp

@@ -1,12 +1,11 @@
 #ifndef ENTT_POLY_FWD_HPP
 #ifndef ENTT_POLY_FWD_HPP
 #define ENTT_POLY_FWD_HPP
 #define ENTT_POLY_FWD_HPP
 
 
-#include <cstdint>
-#include <type_traits>
+#include <cstddef>
 
 
 namespace entt {
 namespace entt {
 
 
-template<typename, std::size_t Len = sizeof(double[2]), std::size_t = alignof(typename std::aligned_storage_t<Len + !Len>)>
+template<typename, std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
 class basic_poly;
 class basic_poly;
 
 
 /**
 /**