From 402f040f16e6c9743bd65dce8f4e42fa09ea356a Mon Sep 17 00:00:00 2001 From: skypjack Date: Fri, 10 Apr 2026 12:00:30 +0200 Subject: [PATCH] stl: std::index_sequence --- src/entt/core/compressed_pair.hpp | 4 ++-- src/entt/core/ident.hpp | 2 +- src/entt/core/type_traits.hpp | 2 +- src/entt/entity/group.hpp | 4 ++-- src/entt/entity/view.hpp | 12 ++++++------ src/entt/meta/utility.hpp | 4 ++-- src/entt/poly/poly.hpp | 2 +- src/entt/signal/delegate.hpp | 6 +++--- src/entt/stl/utility.hpp | 1 + src/entt/tools/davey.hpp | 2 +- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/entt/core/compressed_pair.hpp b/src/entt/core/compressed_pair.hpp index a5447b6c0..1c7991d5c 100644 --- a/src/entt/core/compressed_pair.hpp +++ b/src/entt/core/compressed_pair.hpp @@ -29,7 +29,7 @@ struct compressed_pair_element { : value{stl::forward(arg)} {} template - constexpr compressed_pair_element(stl::tuple args, std::index_sequence) noexcept(stl::is_nothrow_constructible_v) + constexpr compressed_pair_element(stl::tuple args, stl::index_sequence) noexcept(stl::is_nothrow_constructible_v) : value{stl::forward(std::get(args))...} {} [[nodiscard]] constexpr reference get() noexcept { @@ -61,7 +61,7 @@ struct compressed_pair_element: Type { : base_type{stl::forward(arg)} {} template - constexpr compressed_pair_element(stl::tuple args, std::index_sequence) noexcept(stl::is_nothrow_constructible_v) + constexpr compressed_pair_element(stl::tuple args, stl::index_sequence) noexcept(stl::is_nothrow_constructible_v) : base_type{stl::forward(std::get(args))...} {} [[nodiscard]] constexpr reference get() noexcept { diff --git a/src/entt/core/ident.hpp b/src/entt/core/ident.hpp index 68746c6ab..3413393e5 100644 --- a/src/entt/core/ident.hpp +++ b/src/entt/core/ident.hpp @@ -16,7 +16,7 @@ namespace entt { template class ident { template - [[nodiscard]] static ENTT_CONSTEVAL id_type get(std::index_sequence) noexcept { + [[nodiscard]] static ENTT_CONSTEVAL id_type get(stl::index_sequence) noexcept { return (0 + ... + (stl::is_same_v...>>> ? id_type{Index} : id_type{})); } diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 4479fe950..3ea0e9a2e 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -740,7 +740,7 @@ template [[nodiscard]] ENTT_CONSTEVAL bool dispatch_is_equality_comparable(); template -[[nodiscard]] ENTT_CONSTEVAL bool unpack_maybe_equality_comparable(std::index_sequence) { +[[nodiscard]] ENTT_CONSTEVAL bool unpack_maybe_equality_comparable(stl::index_sequence) { return (dispatch_is_equality_comparable>() && ...); } diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 6d7849b0b..ac7c43db0 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -280,7 +280,7 @@ class basic_group, get_t, exclude_t> { static constexpr stl::size_t index_of = type_list_index_v, type_list>; template - [[nodiscard]] auto pools_for(std::index_sequence) const noexcept { + [[nodiscard]] auto pools_for(stl::index_sequence) const noexcept { using return_type = stl::tuple; return descriptor ? return_type{static_cast(descriptor->template storage())...} : return_type{}; } @@ -694,7 +694,7 @@ class basic_group, get_t, exclude_t> { static constexpr stl::size_t index_of = type_list_index_v, type_list>; template - [[nodiscard]] auto pools_for(std::index_sequence, std::index_sequence) const noexcept { + [[nodiscard]] auto pools_for(stl::index_sequence, stl::index_sequence) const noexcept { using return_type = stl::tuple; return descriptor ? return_type{static_cast(descriptor->template storage())..., static_cast(descriptor->template storage())...} : return_type{}; } diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index d977b2d3e..510184239 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -47,7 +47,7 @@ template } template -[[nodiscard]] Result view_pack(const View &view, const Other &other, std::index_sequence, std::index_sequence, std::index_sequence, std::index_sequence) { +[[nodiscard]] Result view_pack(const View &view, const Other &other, stl::index_sequence, stl::index_sequence, stl::index_sequence, stl::index_sequence) { Result elem{}; // friend-initialization, avoid multiple calls to refresh elem.pools = {view.template storage()..., other.template storage()...}; @@ -154,7 +154,7 @@ struct extended_view_iterator final { } [[nodiscard]] reference operator*() const noexcept { - return [this](std::index_sequence) { + return [this](stl::index_sequence) { return stl::tuple_cat(stl::make_tuple(*it), static_cast(const_cast *>(std::get(it.pools)))->get_as_tuple(*it)...); }(stl::index_sequence_for{}); } @@ -211,7 +211,7 @@ class basic_view; template class basic_common_view { template - friend Return internal::view_pack(const View &, const Other &, std::index_sequence, std::index_sequence, std::index_sequence, std::index_sequence); + friend Return internal::view_pack(const View &, const Other &, stl::index_sequence, stl::index_sequence, stl::index_sequence, stl::index_sequence); [[nodiscard]] auto offset() const noexcept { ENTT_ASSERT(index != Get, "Invalid view"); @@ -427,7 +427,7 @@ class basic_view, exclude_t> } template - void each(Func func, std::index_sequence) const { + void each(Func func, stl::index_sequence) const { for(const auto curr: storage()->each()) { if(const auto entt = std::get<0>(curr); (!internal::tombstone_check_v || (entt != tombstone)) && ((Curr == Index || base_type::pool_at(Index)->contains(entt)) && ...) && base_type::none_of(entt)) { if constexpr(is_applicable_v{}, stl::declval().get({})))>) { @@ -593,7 +593,7 @@ public: template [[nodiscard]] decltype(auto) get(const entity_type entt) const { if constexpr(sizeof...(Index) == 0) { - return [this, entt](std::index_sequence) { + return [this, entt](stl::index_sequence) { return stl::tuple_cat(this->storage()->get_as_tuple(entt)...); }(stl::index_sequence_for{}); } else if constexpr(sizeof...(Index) == 1) { @@ -620,7 +620,7 @@ public: */ template void each(Func func) const { - [this, &func](std::index_sequence seq) { + [this, &func](stl::index_sequence seq) { if(const auto *view = base_type::handle(); view != nullptr) { ((view == base_type::pool_at(Index) ? each(stl::move(func), seq) : void()), ...); } diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 86c8fc8b7..1ad935c26 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -205,7 +205,7 @@ template } template -[[nodiscard]] meta_any meta_invoke(meta_any &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, std::index_sequence) { +[[nodiscard]] meta_any meta_invoke(meta_any &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, stl::index_sequence) { using descriptor = meta_function_helper_t>; // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) @@ -228,7 +228,7 @@ template -[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args, std::index_sequence) { +[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args, stl::index_sequence) { // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) if(((args + Index)->allow_cast() && ...)) { return meta_any{ctx, stl::in_place_type, (args + Index)->cast()...}; diff --git a/src/entt/poly/poly.hpp b/src/entt/poly/poly.hpp index 91680d473..e8f6a06b8 100644 --- a/src/entt/poly/poly.hpp +++ b/src/entt/poly/poly.hpp @@ -95,7 +95,7 @@ class poly_vtable { } template - [[nodiscard]] static auto fill_vtable(std::index_sequence) noexcept { + [[nodiscard]] static auto fill_vtable(stl::index_sequence) noexcept { vtable_type impl{}; (fill_vtable_entry>>(std::get(impl)), ...); return impl; diff --git a/src/entt/signal/delegate.hpp b/src/entt/signal/delegate.hpp index d6cf53f60..671e276ef 100644 --- a/src/entt/signal/delegate.hpp +++ b/src/entt/signal/delegate.hpp @@ -69,7 +69,7 @@ class delegate { using delegate_type = return_type(const void *, Args...); template - [[nodiscard]] auto wrap(std::index_sequence) noexcept { + [[nodiscard]] auto wrap(stl::index_sequence) noexcept { return [](const void *, Args... args) -> return_type { [[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward(args)...); [[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v>...> * (sizeof...(Args) - sizeof...(Index)); @@ -78,7 +78,7 @@ class delegate { } template - [[nodiscard]] auto wrap(Type &, std::index_sequence) noexcept { + [[nodiscard]] auto wrap(Type &, stl::index_sequence) noexcept { return [](const void *payload, Args... args) -> return_type { Type *curr = static_cast(const_cast *>(payload)); [[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward(args)...); @@ -88,7 +88,7 @@ class delegate { } template - [[nodiscard]] auto wrap(Type *, std::index_sequence) noexcept { + [[nodiscard]] auto wrap(Type *, stl::index_sequence) noexcept { return [](const void *payload, Args... args) -> return_type { Type *curr = static_cast(const_cast *>(payload)); [[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward(args)...); diff --git a/src/entt/stl/utility.hpp b/src/entt/stl/utility.hpp index 744eccc03..a7b396598 100644 --- a/src/entt/stl/utility.hpp +++ b/src/entt/stl/utility.hpp @@ -14,6 +14,7 @@ using std::in_place; using std::in_place_t; using std::in_place_type; using std::in_place_type_t; +using std::index_sequence; using std::index_sequence_for; using std::make_pair; using std::move; diff --git a/src/entt/tools/davey.hpp b/src/entt/tools/davey.hpp index 2441cca44..901b28084 100644 --- a/src/entt/tools/davey.hpp +++ b/src/entt/tools/davey.hpp @@ -195,7 +195,7 @@ static void present_entity(const meta_ctx &ctx, const Entity entt, const It from } template -static void present_view(const meta_ctx &ctx, const basic_view, exclude_t> &view, std::index_sequence) { +static void present_view(const meta_ctx &ctx, const basic_view, exclude_t> &view, stl::index_sequence) { using view_type = basic_view, exclude_t>; const stl::array range{view.template storage()...};