stl: std::index_sequence_for
This commit is contained in:
@@ -142,8 +142,8 @@ public:
|
||||
*/
|
||||
template<typename... Args, typename... Other>
|
||||
constexpr compressed_pair(stl::piecewise_construct_t, stl::tuple<Args...> args, stl::tuple<Other...> other) noexcept(stl::is_nothrow_constructible_v<first_base, Args...> && stl::is_nothrow_constructible_v<second_base, Other...>)
|
||||
: first_base{stl::move(args), std::index_sequence_for<Args...>{}},
|
||||
second_base{stl::move(other), std::index_sequence_for<Other...>{}} {}
|
||||
: first_base{stl::move(args), stl::index_sequence_for<Args...>{}},
|
||||
second_base{stl::move(other), stl::index_sequence_for<Other...>{}} {}
|
||||
|
||||
/*! @brief Default destructor. */
|
||||
~compressed_pair() = default;
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
/*! @brief Statically generated unique identifier for the given type. */
|
||||
template<typename Curr>
|
||||
requires (stl::is_same_v<stl::remove_cvref_t<Curr>, Type> || ...)
|
||||
static constexpr value_type value = get<stl::remove_cvref_t<Curr>>(std::index_sequence_for<Type...>{});
|
||||
static constexpr value_type value = get<stl::remove_cvref_t<Curr>>(stl::index_sequence_for<Type...>{});
|
||||
};
|
||||
|
||||
} // namespace entt
|
||||
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
*/
|
||||
template<stl::size_t... Index>
|
||||
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
||||
const auto cpools = pools_for(std::index_sequence_for<Get...>{});
|
||||
const auto cpools = pools_for(stl::index_sequence_for<Get...>{});
|
||||
|
||||
if constexpr(sizeof...(Index) == 0) {
|
||||
return stl::apply([entt](auto *...curr) { return stl::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
|
||||
@@ -558,7 +558,7 @@ public:
|
||||
* @return An iterable object to use to _visit_ the group.
|
||||
*/
|
||||
[[nodiscard]] iterable each() const noexcept {
|
||||
const auto cpools = pools_for(std::index_sequence_for<Get...>{});
|
||||
const auto cpools = pools_for(stl::index_sequence_for<Get...>{});
|
||||
return iterable{{begin(), cpools}, {end(), cpools}};
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ public:
|
||||
static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
|
||||
descriptor->handle().sort(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
|
||||
} else {
|
||||
auto comp = [&compare, cpools = pools_for(std::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
|
||||
auto comp = [&compare, cpools = pools_for(stl::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
|
||||
if constexpr(sizeof...(Index) == 1) {
|
||||
return compare((std::get<Index>(cpools)->get(lhs), ...), (std::get<Index>(cpools)->get(rhs), ...));
|
||||
} else {
|
||||
@@ -899,7 +899,7 @@ public:
|
||||
*/
|
||||
template<stl::size_t... Index>
|
||||
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
|
||||
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
|
||||
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
|
||||
|
||||
if constexpr(sizeof...(Index) == 0) {
|
||||
return stl::apply([entt](auto *...curr) { return stl::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
|
||||
@@ -957,7 +957,7 @@ public:
|
||||
* @return An iterable object to use to _visit_ the group.
|
||||
*/
|
||||
[[nodiscard]] iterable each() const noexcept {
|
||||
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
|
||||
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
|
||||
return iterable{{begin(), cpools}, {end(), cpools}};
|
||||
}
|
||||
|
||||
@@ -1015,7 +1015,7 @@ public:
|
||||
*/
|
||||
template<stl::size_t... Index, typename Compare, typename Sort = std_sort, typename... Args>
|
||||
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) const {
|
||||
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
|
||||
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
|
||||
|
||||
if constexpr(sizeof...(Index) == 0) {
|
||||
static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
|
||||
|
||||
@@ -156,7 +156,7 @@ struct extended_view_iterator final {
|
||||
[[nodiscard]] reference operator*() const noexcept {
|
||||
return [this]<auto... Index>(std::index_sequence<Index...>) {
|
||||
return stl::tuple_cat(stl::make_tuple(*it), static_cast<Get *>(const_cast<constness_as_t<typename Get::base_type, Get> *>(std::get<Index>(it.pools)))->get_as_tuple(*it)...);
|
||||
}(std::index_sequence_for<Get...>{});
|
||||
}(stl::index_sequence_for<Get...>{});
|
||||
}
|
||||
|
||||
[[nodiscard]] pointer operator->() const noexcept {
|
||||
@@ -595,7 +595,7 @@ public:
|
||||
if constexpr(sizeof...(Index) == 0) {
|
||||
return [this, entt]<auto... Idx>(std::index_sequence<Idx...>) {
|
||||
return stl::tuple_cat(this->storage<Idx>()->get_as_tuple(entt)...);
|
||||
}(std::index_sequence_for<Get...>{});
|
||||
}(stl::index_sequence_for<Get...>{});
|
||||
} else if constexpr(sizeof...(Index) == 1) {
|
||||
return (storage<Index>()->get(entt), ...);
|
||||
} else {
|
||||
@@ -624,7 +624,7 @@ public:
|
||||
if(const auto *view = base_type::handle(); view != nullptr) {
|
||||
((view == base_type::pool_at(Index) ? each<Index>(stl::move(func), seq) : void()), ...);
|
||||
}
|
||||
}(std::index_sequence_for<Get...>{});
|
||||
}(stl::index_sequence_for<Get...>{});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +661,7 @@ public:
|
||||
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
|
||||
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
|
||||
return internal::view_pack<basic_view<get_t<Get..., OGet...>, exclude_t<Exclude..., OExclude...>>>(
|
||||
*this, other, std::index_sequence_for<Get...>{}, std::index_sequence_for<Exclude...>{}, std::index_sequence_for<OGet...>{}, std::index_sequence_for<OExclude...>{});
|
||||
*this, other, stl::index_sequence_for<Get...>{}, stl::index_sequence_for<Exclude...>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1117,7 +1117,7 @@ public:
|
||||
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
|
||||
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
|
||||
return internal::view_pack<basic_view<get_t<Get, OGet...>, exclude_t<OExclude...>>>(
|
||||
*this, other, std::index_sequence_for<Get>{}, std::index_sequence_for<>{}, std::index_sequence_for<OGet...>{}, std::index_sequence_for<OExclude...>{});
|
||||
*this, other, stl::index_sequence_for<Get>{}, stl::index_sequence_for<>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ template<typename Type, auto Candidate, meta_policy Policy = as_value_t>
|
||||
*/
|
||||
template<typename Type, typename... Args>
|
||||
[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args) {
|
||||
return internal::meta_construct<Type, Args...>(ctx, args, std::index_sequence_for<Args...>{});
|
||||
return internal::meta_construct<Type, Args...>(ctx, args, stl::index_sequence_for<Args...>{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ using function_pointer_t = decltype(function_pointer(stl::declval<Type>()...));
|
||||
|
||||
template<typename... Class, typename Ret, typename... Args>
|
||||
[[nodiscard]] ENTT_CONSTEVAL auto index_sequence_for(Ret (*)(Args...)) {
|
||||
return std::index_sequence_for<Class..., Args...>{};
|
||||
return stl::index_sequence_for<Class..., Args...>{};
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@@ -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_for;
|
||||
using std::make_pair;
|
||||
using std::move;
|
||||
using std::pair;
|
||||
|
||||
@@ -268,7 +268,7 @@ void davey(const basic_storage<Type, Entity, Allocator> &storage) {
|
||||
*/
|
||||
template<typename... Get, typename... Exclude>
|
||||
void davey(const meta_ctx &ctx, const basic_view<get_t<Get...>, exclude_t<Exclude...>> &view) {
|
||||
internal::present_view(ctx, view, std::index_sequence_for<Get...>{});
|
||||
internal::present_view(ctx, view, stl::index_sequence_for<Get...>{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user