storage: void returned value type for storage entity

This commit is contained in:
Michele Caini
2023-11-10 10:25:47 +01:00
parent dc184c10e2
commit 5e8544cfc6
2 changed files with 16 additions and 16 deletions

View File

@@ -1009,7 +1009,7 @@ public:
* @param allocator The allocator to use.
*/
explicit basic_storage(const allocator_type &allocator)
: base_type{type_id<value_type>(), deletion_policy::swap_only, allocator} {}
: base_type{type_id<void>(), deletion_policy::swap_only, allocator} {}
/**
* @brief Move constructor.

View File

@@ -17,13 +17,13 @@ TEST(StorageEntity, Constructors) {
ASSERT_EQ(pool.policy(), entt::deletion_policy::swap_only);
ASSERT_NO_FATAL_FAILURE([[maybe_unused]] auto alloc = pool.get_allocator());
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
pool = entt::storage<entt::entity>{std::allocator<entt::entity>{}};
ASSERT_EQ(pool.policy(), entt::deletion_policy::swap_only);
ASSERT_NO_FATAL_FAILURE([[maybe_unused]] auto alloc = pool.get_allocator());
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
}
TEST(StorageEntity, Move) {
@@ -39,8 +39,8 @@ TEST(StorageEntity, Move) {
ASSERT_TRUE(pool.empty());
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), entt::entity{3});
@@ -50,8 +50,8 @@ TEST(StorageEntity, Move) {
ASSERT_TRUE(other.empty());
ASSERT_FALSE(extended.empty());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(extended.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(extended.type(), entt::type_id<void>());
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(extended.at(0u), entt::entity{3});
@@ -62,9 +62,9 @@ TEST(StorageEntity, Move) {
ASSERT_TRUE(other.empty());
ASSERT_TRUE(extended.empty());
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(extended.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(extended.type(), entt::type_id<void>());
ASSERT_EQ(pool.at(0u), entt::entity{3});
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
@@ -77,8 +77,8 @@ TEST(StorageEntity, Move) {
ASSERT_TRUE(pool.empty());
ASSERT_FALSE(other.empty());
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(pool.at(0u), static_cast<entt::entity>(entt::null));
ASSERT_EQ(other.at(0u), entt::entity{3});
@@ -88,8 +88,8 @@ TEST(StorageEntity, Swap) {
entt::storage<entt::entity> pool;
entt::storage<entt::entity> other;
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
pool.emplace(entt::entity{42});
@@ -102,8 +102,8 @@ TEST(StorageEntity, Swap) {
pool.swap(other);
ASSERT_EQ(pool.type(), entt::type_id<entt::entity>());
ASSERT_EQ(other.type(), entt::type_id<entt::entity>());
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_EQ(other.type(), entt::type_id<void>());
ASSERT_EQ(pool.size(), 10u);
ASSERT_EQ(other.size(), 43u);