entity: explicit casts to suppress misleading warnings

This commit is contained in:
Michele Caini
2020-07-16 17:48:29 +02:00
parent 045c2a6f05
commit 13502e5467
2 changed files with 8 additions and 8 deletions

View File

@@ -474,7 +474,7 @@ public:
entity_type entt;
if(destroyed == null) {
entt = entities.emplace_back(entity_type(entities.size()));
entt = entities.emplace_back(entity_type(static_cast<typename traits_type::entity_type>(entities.size())));
// traits_type::entity_mask is reserved to allow for null identifiers
ENTT_ASSERT(to_integral(entt) < traits_type::entity_mask);
} else {
@@ -507,7 +507,7 @@ public:
for(auto pos = entities.size(); pos < req; ++pos) {
entities.emplace_back(destroyed);
destroyed = entity_type(pos);
destroyed = entity_type(static_cast<typename traits_type::entity_type>(pos));
}
entt = entities.emplace_back(hint);
@@ -562,7 +562,7 @@ public:
if((to_integral(entities[pos]) & traits_type::entity_mask) != pos) {
const auto version = to_integral(entities[pos]) & (traits_type::version_mask << traits_type::entity_shift);
entities[pos] = entity_type{to_integral(destroyed) | version};
destroyed = entity_type(pos);
destroyed = entity_type(static_cast<typename traits_type::entity_type>(pos));
}
}
}

View File

@@ -364,7 +364,7 @@ public:
*/
void emplace(const entity_type entt) {
ENTT_ASSERT(!contains(entt));
assure(page(entt))[offset(entt)] = entity_type(packed.size());
assure(page(entt))[offset(entt)] = entity_type(static_cast<typename traits_type::entity_type>(packed.size()));
packed.push_back(entt);
}
@@ -383,7 +383,7 @@ public:
*/
template<typename It>
void insert(It first, It last) {
auto next = packed.size();
auto next = static_cast<typename traits_type::entity_type>(packed.size());
packed.insert(packed.end(), first, last);
while(first != last) {
@@ -408,7 +408,7 @@ public:
ENTT_ASSERT(contains(entt));
const auto curr = page(entt);
const auto pos = offset(entt);
packed[size_type(sparse[curr][pos])] = entity_type(packed.back());
packed[size_type(sparse[curr][pos])] = packed.back();
sparse[page(packed.back())][offset(packed.back())] = sparse[curr][pos];
sparse[curr][pos] = null;
packed.pop_back();
@@ -483,7 +483,7 @@ public:
algo(from, to, std::move(compare), std::forward<Args>(args)...);
for(size_type pos = skip, end = skip+length; pos < end; ++pos) {
sparse[page(packed[pos])][offset(packed[pos])] = entity_type(pos);
sparse[page(packed[pos])][offset(packed[pos])] = entity_type(static_cast<typename traits_type::entity_type>(pos));
}
}
@@ -532,7 +532,7 @@ public:
while(curr != next) {
apply(packed[curr], packed[next]);
sparse[page(packed[curr])][offset(packed[curr])] = entity_type(curr);
sparse[page(packed[curr])][offset(packed[curr])] = entity_type(static_cast<typename traits_type::entity_type>(curr));
curr = next;
next = index(packed[curr]);