From 4ad411e320b109c8d955f7779c0f7af034b6d642 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 28 Oct 2020 22:58:26 +0100 Subject: [PATCH] traits: is_eto_eligible[_v] -> is_empty[_v], internal version --- src/entt/core/type_traits.hpp | 4 ++-- src/entt/entity/group.hpp | 22 +++++++++++----------- src/entt/entity/pool.hpp | 4 ++-- src/entt/entity/storage.hpp | 2 +- src/entt/entity/view.hpp | 16 +++++++--------- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 7c3012637..f1e92806e 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -309,7 +309,7 @@ inline constexpr auto is_applicable_r_v = is_applicable_r::valu * @tparam Type Potential empty type. */ template -struct is_eto_eligible +struct is_empty : ENTT_IS_EMPTY(Type) {}; @@ -319,7 +319,7 @@ struct is_eto_eligible * @tparam Type Potential empty type. */ template -inline constexpr auto is_eto_eligible_v = is_eto_eligible::value; +inline constexpr auto is_empty_v = is_empty::value; /** diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 1e68f9435..f21f5a526 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -129,11 +129,11 @@ class basic_group, get_t> final { public: using iterator = iterable_group_iterator< typename basic_sparse_set::iterator, - type_list_cat_t, type_list<>, type_list>...> + type_list_cat_t, type_list<>, type_list>...> >; using reverse_iterator = iterable_group_iterator< typename basic_sparse_set::reverse_iterator, - type_list_cat_t, type_list<>, type_list>...> + type_list_cat_t, type_list<>, type_list>...> >; [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { @@ -408,7 +408,7 @@ public: if constexpr(sizeof...(Component) == 0) { return std::tuple_cat([entt](auto *cpool) { - if constexpr(is_eto_eligible_v::value_type>) { + if constexpr(is_empty_v::value_type>) { return std::tuple{}; } else { return std::forward_as_tuple(cpool->get(entt)); @@ -445,7 +445,7 @@ public: */ template void each(Func func) const { - traverse(std::move(func), (std::conditional_t, type_list<>, type_list>{} + ...)); + traverse(std::move(func), (std::conditional_t, type_list<>, type_list>{} + ...)); } /** @@ -661,13 +661,13 @@ class basic_group, get_t, Owned...> final public: using iterator = iterable_group_iterator< typename basic_sparse_set::iterator, - type_list_cat_t, type_list<>, type_list>().end())>>...>, - type_list_cat_t, type_list<>, type_list>...> + type_list_cat_t, type_list<>, type_list>().end())>>...>, + type_list_cat_t, type_list<>, type_list>...> >; using reverse_iterator = iterable_group_iterator< typename basic_sparse_set::reverse_iterator, - type_list_cat_t, type_list<>, type_list>().rbegin())>>...>, - type_list_cat_t, type_list<>, type_list>...> + type_list_cat_t, type_list<>, type_list>().rbegin())>>...>, + type_list_cat_t, type_list<>, type_list>...> >; [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { @@ -957,7 +957,7 @@ public: auto filter = [entt, index = std::get<0>(pools)->index(entt)](auto *cpool) { using value_type = typename std::remove_reference_t::value_type; - if constexpr(is_eto_eligible_v) { + if constexpr(is_empty_v) { return std::tuple{}; } else if constexpr((std::is_same_v> || ...)) { return std::forward_as_tuple(cpool->raw()[index]); @@ -999,8 +999,8 @@ public: template void each(Func func) const { traverse(std::move(func), - (std::conditional_t, type_list<>, type_list>{} + ...), - (type_list<>{} + ... + std::conditional_t, type_list<>, type_list>{})); + (std::conditional_t, type_list<>, type_list>{} + ...), + (type_list<>{} + ... + std::conditional_t, type_list<>, type_list>{})); } /** diff --git a/src/entt/entity/pool.hpp b/src/entt/entity/pool.hpp index 03af45732..380dd4bf7 100644 --- a/src/entt/entity/pool.hpp +++ b/src/entt/entity/pool.hpp @@ -179,7 +179,7 @@ struct sigh_pool_mixin: Pool { Pool::emplace(owner, entity, std::forward(args)...); construction.publish(owner, entity); - if constexpr(!is_eto_eligible_v) { + if constexpr(!is_empty_v) { return this->get(entity); } } @@ -244,7 +244,7 @@ struct sigh_pool_mixin: Pool { */ template decltype(auto) patch(basic_registry &owner, const entity_type entity, [[maybe_unused]] Func &&... func) { - if constexpr(is_eto_eligible_v) { + if constexpr(is_empty_v) { update.publish(owner, entity); } else { Pool::patch(owner, entity, std::forward(func)...); diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index 4ab903fcb..e5dfec304 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -535,7 +535,7 @@ private: /*! @copydoc basic_storage */ template -class basic_storage>>: public basic_sparse_set { +class basic_storage>>: public basic_sparse_set { using underlying_type = basic_sparse_set; public: diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index 0091e2ad5..bf1f41788 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -71,7 +71,7 @@ class basic_view, Component...> final { template using pool_type = pool_t; - using return_type = type_list_cat_t, type_list<>, type_list>...>; + using return_type = type_list_cat_t, type_list<>, type_list>...>; using unchecked_type = std::array *, (sizeof...(Component) - 1)>; template @@ -290,9 +290,7 @@ class basic_view, Component...> final { auto first = view->data(); while(first != last) { - if((std::get *>(pools)->contains(*first) && ...) - && !(std::get *>(filter)->contains(*first) || ...)) - { + if((std::get *>(pools)->contains(*first) && ...) && !(std::get *>(filter)->contains(*first) || ...)) { const auto base = *(first++); const auto chunk = (std::min)({ (std::get *>(pools)->size() - std::get *>(pools)->index(base))... }); size_type length{}; @@ -443,7 +441,7 @@ public: if constexpr(sizeof...(Comp) == 0) { return std::tuple_cat([entt](auto *cpool) { - if constexpr(is_eto_eligible_v::value_type>) { + if constexpr(is_empty_v::value_type>) { return std::tuple{}; } else { return std::forward_as_tuple(cpool->get(entt)); @@ -674,12 +672,12 @@ class basic_view, Component> final { public: using iterator = std::conditional_t< - is_eto_eligible_v, + is_empty_v, iterable_view_iterator::iterator>, iterable_view_iterator::iterator, decltype(std::declval().begin())> >; using reverse_iterator = std::conditional_t< - is_eto_eligible_v, + is_empty_v, iterable_view_iterator::reverse_iterator>, iterable_view_iterator::reverse_iterator, decltype(std::declval().rbegin())> >; @@ -889,7 +887,7 @@ public: template [[nodiscard]] decltype(auto) get(const entity_type entt) const { if constexpr(sizeof...(Comp) == 0) { - if constexpr(is_eto_eligible_v) { + if constexpr(is_empty_v) { return std::tuple{}; } else { return std::forward_as_tuple(pool->get(entt)); @@ -924,7 +922,7 @@ public: */ template void each(Func func) const { - if constexpr(is_eto_eligible_v) { + if constexpr(is_empty_v) { if constexpr(std::is_invocable_v) { for(const auto entt: *this) { func(entt);