Browse Source

storage/mixin: prefer NOLINTBEGIN/END on the right (wrong) warning

Michele Caini 1 year ago
parent
commit
f86c325f0b
2 changed files with 18 additions and 7 deletions
  1. 6 2
      src/entt/entity/mixin.hpp
  2. 12 5
      src/entt/entity/storage.hpp

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

@@ -176,24 +176,28 @@ public:
      * @brief Move constructor.
      * @param other The instance to move from.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_sigh_mixin(basic_sigh_mixin &&other) noexcept
-        : underlying_type{static_cast<underlying_type &&>(other)},
+        : underlying_type{std::move(other)},
           owner{other.owner},
           construction{std::move(other.construction)},
           destruction{std::move(other.destruction)},
           update{std::move(other.update)} {}
+    // NOLINTEND(bugprone-use-after-move)
 
     /**
      * @brief Allocator-extended move constructor.
      * @param other The instance to move from.
      * @param allocator The allocator to use.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_sigh_mixin(basic_sigh_mixin &&other, const allocator_type &allocator)
-        : underlying_type{static_cast<underlying_type &&>(other), allocator},
+        : underlying_type{std::move(other), allocator},
           owner{other.owner},
           construction{std::move(other.construction), allocator},
           destruction{std::move(other.destruction), allocator},
           update{std::move(other.update), allocator} {}
+    // NOLINTEND(bugprone-use-after-move)
 
     /*! @brief Default destructor. */
     ~basic_sigh_mixin() override = default;

+ 12 - 5
src/entt/entity/storage.hpp

@@ -449,21 +449,24 @@ public:
      * @brief Move constructor.
      * @param other The instance to move from.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_storage(basic_storage &&other) noexcept
-        : base_type{static_cast<base_type &&>(other)},
+        : base_type{std::move(other)},
           payload{std::move(other.payload)} {}
+    // NOLINTEND(bugprone-use-after-move)
 
     /**
      * @brief Allocator-extended move constructor.
      * @param other The instance to move from.
      * @param allocator The allocator to use.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_storage(basic_storage &&other, const allocator_type &allocator)
-        : base_type{static_cast<base_type &&>(other), allocator},
+        : base_type{std::move(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");
     }
+    // NOLINTEND(bugprone-use-after-move)
 
     /*! @brief Default destructor. */
     // NOLINTNEXTLINE(bugprone-exception-escape)
@@ -1055,18 +1058,22 @@ public:
      * @brief Move constructor.
      * @param other The instance to move from.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_storage(basic_storage &&other) noexcept
-        : base_type{static_cast<base_type &&>(other)},
+        : base_type{std::move(other)},
           placeholder{other.placeholder} {}
+    // NOLINTEND(bugprone-use-after-move)
 
     /**
      * @brief Allocator-extended move constructor.
      * @param other The instance to move from.
      * @param allocator The allocator to use.
      */
+    // NOLINTBEGIN(bugprone-use-after-move)
     basic_storage(basic_storage &&other, const allocator_type &allocator)
-        : base_type{static_cast<base_type &&>(other), allocator},
+        : base_type{std::move(other), allocator},
           placeholder{other.placeholder} {}
+    // NOLINTEND(bugprone-use-after-move)
 
     /*! @brief Default destructor. */
     ~basic_storage() override = default;