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

storage/mixin: avoid use-after-move (wrong) warnings

Michele Caini 1 год назад
Родитель
Сommit
38551a5332
2 измененных файлов с 6 добавлено и 6 удалено
  1. 2 2
      src/entt/entity/mixin.hpp
  2. 4 4
      src/entt/entity/storage.hpp

+ 2 - 2
src/entt/entity/mixin.hpp

@@ -177,7 +177,7 @@ public:
      * @param other The instance to move from.
      */
     basic_sigh_mixin(basic_sigh_mixin &&other) noexcept
-        : underlying_type{std::move(other)},
+        : underlying_type{static_cast<underlying_type &&>(other)},
           owner{other.owner},
           construction{std::move(other.construction)},
           destruction{std::move(other.destruction)},
@@ -189,7 +189,7 @@ public:
      * @param allocator The allocator to use.
      */
     basic_sigh_mixin(basic_sigh_mixin &&other, const allocator_type &allocator)
-        : underlying_type{std::move(other), allocator},
+        : underlying_type{static_cast<underlying_type &&>(other), allocator},
           owner{other.owner},
           construction{std::move(other.construction), allocator},
           destruction{std::move(other.destruction), allocator},

+ 4 - 4
src/entt/entity/storage.hpp

@@ -450,7 +450,7 @@ public:
      * @param other The instance to move from.
      */
     basic_storage(basic_storage &&other) noexcept
-        : base_type{std::move(other)},
+        : base_type{static_cast<base_type &&>(other)},
           payload{std::move(other.payload)} {}
 
     /**
@@ -459,7 +459,7 @@ public:
      * @param allocator The allocator to use.
      */
     basic_storage(basic_storage &&other, const allocator_type &allocator)
-        : base_type{std::move(other), allocator},
+        : base_type{static_cast<base_type &&>(other), allocator},
           payload{std::move(other.payload), allocator} {
         // NOLINTNEXTLINE(bugprone-use-after-move)
         ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a storage is not allowed");
@@ -1056,7 +1056,7 @@ public:
      * @param other The instance to move from.
      */
     basic_storage(basic_storage &&other) noexcept
-        : base_type{std::move(other)},
+        : base_type{static_cast<base_type &&>(other)},
           placeholder{other.placeholder} {}
 
     /**
@@ -1065,7 +1065,7 @@ public:
      * @param allocator The allocator to use.
      */
     basic_storage(basic_storage &&other, const allocator_type &allocator)
-        : base_type{std::move(other), allocator},
+        : base_type{static_cast<base_type &&>(other), allocator},
           placeholder{other.placeholder} {}
 
     /*! @brief Default destructor. */