Преглед изворни кода

storage: quit accepting (and silently discarding) arguments for empty types when invoking ::emplace

skypjack пре 6 месеци
родитељ
комит
a638df6cae

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

@@ -909,12 +909,9 @@ public:
      * Attempting to use an entity that already belongs to the storage results
      * in undefined behavior.
      *
-     * @tparam Args Types of arguments to use to construct the object.
      * @param entt A valid identifier.
      */
-    template<typename... Args>
-    // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
-    void emplace(const entity_type entt, Args &&...) {
+    void emplace(const entity_type entt) {
         base_type::try_emplace(entt, false);
     }
 

+ 1 - 1
test/entt/entity/registry.cpp

@@ -975,7 +975,7 @@ TEST(Registry, EmplaceEmpty) {
 
     ASSERT_FALSE(registry.all_of<test::empty>(entity));
 
-    registry.emplace<test::empty>(entity, 4);
+    registry.emplace<test::empty>(entity);
 
     ASSERT_TRUE(registry.all_of<test::empty>(entity));
 }

+ 4 - 13
test/entt/entity/storage_no_instance.cpp

@@ -22,21 +22,12 @@ struct StorageNoInstance: testing::Test {
     using type = Type;
 
     static auto emplace_instance(entt::storage<type> &pool, const entt::entity entt) {
-        if constexpr(std::is_void_v<type>) {
-            return pool.emplace(entt);
-        } else {
-            return pool.emplace(entt, type{});
-        }
+        return pool.emplace(entt);
     }
 
     template<typename It>
     static auto insert_instance(entt::storage<type> &pool, const It from, const It to) {
-        if constexpr(std::is_void_v<type>) {
-            return pool.insert(from, to);
-        } else {
-            const std::array<type, 2u> value{};
-            return pool.insert(from, to, value.begin());
-        }
+        return pool.insert(from, to);
     }
 
     static auto push_instance(entt::storage<type> &pool, const entt::entity entt) {
@@ -115,7 +106,7 @@ TYPED_TEST(StorageNoInstance, Move) {
     ASSERT_EQ(pool.index(entity[0u]), 0u);
 
     other = entt::storage<value_type>{};
-    other.emplace(entity[1u], 2);
+    other.emplace(entity[1u]);
     other = std::move(pool);
     test::is_initialized(pool);
 
@@ -162,7 +153,7 @@ TYPED_TEST(StorageNoInstance, Getters) {
     entt::storage<value_type> pool;
     const entt::entity entity{4};
 
-    pool.emplace(entity, 3);
+    pool.emplace(entity);
 
     testing::StaticAssertTypeEq<decltype(pool.get({})), void>();
     testing::StaticAssertTypeEq<decltype(std::as_const(pool).get({})), void>();