From fc9eb2a9f2cb99c23c950cd447ae9ae82417351f Mon Sep 17 00:00:00 2001 From: skypjack Date: Tue, 31 Mar 2026 08:56:56 +0200 Subject: [PATCH] stl: std::distance --- src/entt/container/dense_map.hpp | 2 +- src/entt/container/dense_set.hpp | 2 +- src/entt/core/algorithm.hpp | 2 +- src/entt/entity/snapshot.hpp | 2 +- src/entt/entity/sparse_set.hpp | 2 +- src/entt/stl/iterator.hpp | 4 +++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/entt/container/dense_map.hpp b/src/entt/container/dense_map.hpp index abd686772..153620072 100644 --- a/src/entt/container/dense_map.hpp +++ b/src/entt/container/dense_map.hpp @@ -915,7 +915,7 @@ public: * @return The number of elements in the given bucket. */ [[nodiscard]] size_type bucket_size(const size_type index) const { - return static_cast(std::distance(begin(index), end(index))); + return static_cast(stl::distance(begin(index), end(index))); } /** diff --git a/src/entt/container/dense_set.hpp b/src/entt/container/dense_set.hpp index 2a3365863..722c5d5ce 100644 --- a/src/entt/container/dense_set.hpp +++ b/src/entt/container/dense_set.hpp @@ -791,7 +791,7 @@ public: * @return The number of elements in the given bucket. */ [[nodiscard]] size_type bucket_size(const size_type index) const { - return static_cast(std::distance(begin(index), end(index))); + return static_cast(stl::distance(begin(index), end(index))); } /** diff --git a/src/entt/core/algorithm.hpp b/src/entt/core/algorithm.hpp index 4e0a68796..cf692cdbc 100644 --- a/src/entt/core/algorithm.hpp +++ b/src/entt/core/algorithm.hpp @@ -99,7 +99,7 @@ struct radix_sort { using value_type = std::iterator_traits::value_type; using difference_type = std::iterator_traits::difference_type; - stl::vector aux(static_cast(std::distance(first, last))); + stl::vector aux(static_cast(stl::distance(first, last))); auto part = [getter = std::move(getter)](auto from, auto to, auto out, auto start) { constexpr auto mask = (1 << Bit) - 1; diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 1292c4a98..2ab17cb64 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -138,7 +138,7 @@ public: static_assert(!std::is_same_v, "Entity types not supported"); if(const auto *storage = reg->template storage(id); storage && !storage->empty()) { - archive(static_cast(std::distance(first, last))); + archive(static_cast(stl::distance(first, last))); for(; first != last; ++first) { if(const auto entt = *first; storage->contains(entt)) { diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 1c6b282f7..e43f0feb1 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -873,7 +873,7 @@ public: ++first; } - count += static_cast(std::distance(it, first)); + count += static_cast(stl::distance(it, first)); erase(it, first); } } else { diff --git a/src/entt/stl/iterator.hpp b/src/entt/stl/iterator.hpp index a996fd050..d368d7960 100644 --- a/src/entt/stl/iterator.hpp +++ b/src/entt/stl/iterator.hpp @@ -10,9 +10,11 @@ namespace entt::stl { using std::bidirectional_iterator_tag; using std::forward_iterator_tag; using std::input_iterator_tag; -using std::make_reverse_iterator; using std::random_access_iterator_tag; +using std::distance; +using std::make_reverse_iterator; + #ifndef ENTT_FORCE_STL # if __has_include() # include