Procházet zdrojové kódy

storage: drop deprecated functions

Michele Caini před 1 rokem
rodič
revize
5ccb46383c
2 změnil soubory, kde provedl 31 přidání a 63 odebrání
  1. 0 32
      src/entt/entity/storage.hpp
  2. 31 31
      test/entt/entity/storage_entity.cpp

+ 0 - 32
src/entt/entity/storage.hpp

@@ -1175,27 +1175,6 @@ public:
         }
         }
     }
     }
 
 
-    /**
-     * @brief Creates a new identifier or recycles a destroyed one.
-     * @return A valid identifier.
-     */
-    [[deprecated("use ::generate() instead")]] entity_type emplace() {
-        return generate();
-    }
-
-    /**
-     * @brief Creates a new identifier or recycles a destroyed one.
-     *
-     * If the requested identifier isn't in use, the suggested one is used.
-     * Otherwise, a new identifier is returned.
-     *
-     * @param hint Required identifier.
-     * @return A valid identifier.
-     */
-    [[deprecated("use ::generate(hint) instead")]] entity_type emplace(const entity_type hint) {
-        return generate(hint);
-    }
-
     /**
     /**
      * @brief Updates a given identifier.
      * @brief Updates a given identifier.
      * @tparam Func Types of the function objects to invoke.
      * @tparam Func Types of the function objects to invoke.
@@ -1208,17 +1187,6 @@ public:
         (std::forward<Func>(func)(), ...);
         (std::forward<Func>(func)(), ...);
     }
     }
 
 
-    /**
-     * @brief Assigns each element in a range an identifier.
-     * @tparam It Type of mutable forward iterator.
-     * @param first An iterator to the first element of the range to generate.
-     * @param last An iterator past the last element of the range to generate.
-     */
-    template<typename It>
-    [[deprecated("use ::generate(first, last) instead")]] void insert(It first, It last) {
-        generate(std::move(first), std::move(last));
-    }
-
     /**
     /**
      * @brief Returns an iterable object to use to _visit_ a storage.
      * @brief Returns an iterable object to use to _visit_ a storage.
      *
      *

+ 31 - 31
test/entt/entity/storage_entity.cpp

@@ -143,10 +143,10 @@ TEST(StorageEntity, Generate) {
     entt::storage<entt::entity> pool;
     entt::storage<entt::entity> pool;
     std::array<entt::entity, 2u> entity{};
     std::array<entt::entity, 2u> entity{};
 
 
-    ASSERT_EQ(pool.emplace(), entt::entity{0});
+    ASSERT_EQ(pool.generate(), entt::entity{0});
     ASSERT_EQ(pool.generate(entt::null), entt::entity{1});
     ASSERT_EQ(pool.generate(entt::null), entt::entity{1});
     ASSERT_EQ(pool.generate(entt::tombstone), entt::entity{2});
     ASSERT_EQ(pool.generate(entt::tombstone), entt::entity{2});
-    ASSERT_EQ(pool.emplace(entt::entity{0}), entt::entity{3});
+    ASSERT_EQ(pool.generate(entt::entity{0}), entt::entity{3});
     ASSERT_EQ(pool.generate(traits_type::construct(1, 1)), entt::entity{4});
     ASSERT_EQ(pool.generate(traits_type::construct(1, 1)), entt::entity{4});
     ASSERT_EQ(pool.generate(traits_type::construct(6, 3)), traits_type::construct(6, 3));
     ASSERT_EQ(pool.generate(traits_type::construct(6, 3)), traits_type::construct(6, 3));
 
 
@@ -172,6 +172,35 @@ TEST(StorageEntity, Generate) {
     ASSERT_EQ(entity[1u], entt::entity{8});
     ASSERT_EQ(entity[1u], entt::entity{8});
 }
 }
 
 
+TEST(StorageEntity, GenerateRange) {
+    entt::storage<entt::entity> pool;
+    std::array<entt::entity, 2u> entity{};
+
+    pool.generate(entity.begin(), entity.end());
+
+    ASSERT_TRUE(pool.contains(entity[0u]));
+    ASSERT_TRUE(pool.contains(entity[1u]));
+
+    ASSERT_FALSE(pool.empty());
+    ASSERT_EQ(pool.size(), 2u);
+    ASSERT_EQ(pool.free_list(), 2u);
+
+    pool.erase(entity.begin(), entity.end());
+
+    ASSERT_FALSE(pool.empty());
+    ASSERT_EQ(pool.size(), 2u);
+    ASSERT_EQ(pool.free_list(), 0u);
+
+    pool.generate(entity.begin(), entity.begin() + 1u);
+
+    ASSERT_TRUE(pool.contains(entity[0u]));
+    ASSERT_FALSE(pool.contains(entity[1u]));
+
+    ASSERT_FALSE(pool.empty());
+    ASSERT_EQ(pool.size(), 2u);
+    ASSERT_EQ(pool.free_list(), 1u);
+}
+
 TEST(StorageEntity, GenerateFrom) {
 TEST(StorageEntity, GenerateFrom) {
     entt::storage<entt::entity> pool;
     entt::storage<entt::entity> pool;
     std::array entity{entt::entity{0}, entt::entity{1}, entt::entity{2}};
     std::array entity{entt::entity{0}, entt::entity{1}, entt::entity{2}};
@@ -287,35 +316,6 @@ ENTT_DEBUG_TEST(StorageEntityDeathTest, Patch) {
     ASSERT_DEATH(pool.patch(entt::null), "");
     ASSERT_DEATH(pool.patch(entt::null), "");
 }
 }
 
 
-TEST(StorageEntity, Insert) {
-    entt::storage<entt::entity> pool;
-    std::array<entt::entity, 2u> entity{};
-
-    pool.insert(entity.begin(), entity.end());
-
-    ASSERT_TRUE(pool.contains(entity[0u]));
-    ASSERT_TRUE(pool.contains(entity[1u]));
-
-    ASSERT_FALSE(pool.empty());
-    ASSERT_EQ(pool.size(), 2u);
-    ASSERT_EQ(pool.free_list(), 2u);
-
-    pool.erase(entity.begin(), entity.end());
-
-    ASSERT_FALSE(pool.empty());
-    ASSERT_EQ(pool.size(), 2u);
-    ASSERT_EQ(pool.free_list(), 0u);
-
-    pool.generate(entity.begin(), entity.begin() + 1u);
-
-    ASSERT_TRUE(pool.contains(entity[0u]));
-    ASSERT_FALSE(pool.contains(entity[1u]));
-
-    ASSERT_FALSE(pool.empty());
-    ASSERT_EQ(pool.size(), 2u);
-    ASSERT_EQ(pool.free_list(), 1u);
-}
-
 TEST(StorageEntity, Pack) {
 TEST(StorageEntity, Pack) {
     entt::storage<entt::entity> pool;
     entt::storage<entt::entity> pool;
     std::array entity{entt::entity{1}, entt::entity{3}, entt::entity{4}, entt::entity{2}};
     std::array entity{entt::entity{1}, entt::entity{3}, entt::entity{4}, entt::entity{2}};