view/group: proxy() -> each() (breaking changes - I know, I shouldn't have changed it before)

This commit is contained in:
Michele Caini
2020-10-15 10:06:00 +02:00
parent cb27a7fe3e
commit 559ee931fb
5 changed files with 116 additions and 116 deletions

View File

@@ -1357,8 +1357,8 @@ for(auto entity: view) {
}
```
Or rely on the `each` and `proxy` member functions to iterate both entities and
components at once:
Or rely on the `each` member functions to iterate both entities and components
at once:
```cpp
// through a callback
@@ -1367,7 +1367,7 @@ registry.view<position, velocity>().each([](auto entity, auto &pos, auto &vel) {
});
// using an input iterator
for(auto &&[entity, pos, vel]: registry.view<position, velocity>().proxy()) {
for(auto &&[entity, pos, vel]: registry.view<position, velocity>().each()) {
// ...
}
```
@@ -1518,8 +1518,8 @@ for(auto entity: group) {
}
```
Or rely on the `each` and `proxy` member functions to iterate both entities and
components at once:
Or rely on the `each` member functions to iterate both entities and components
at once:
```cpp
// through a callback
@@ -1528,7 +1528,7 @@ registry.group<position>(entt::get<velocity>).each([](auto entity, auto &pos, au
});
// using an input iterator
for(auto &&[entity, pos, vel]: registry.group<position>(entt::get<velocity>).proxy()) {
for(auto &&[entity, pos, vel]: registry.group<position>(entt::get<velocity>).each()) {
// ...
}
```

View File

@@ -71,16 +71,16 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
template<typename Component>
using pool_type = pool_t<Entity, Component>;
class group_proxy {
class iterable_group {
friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>>;
class proxy_iterator {
friend class group_proxy;
class iterable_group_iterator {
friend class iterable_group;
using it_type = typename basic_sparse_set<Entity>::iterator;
using ref_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<pool_type<Get> *>>>()...));
proxy_iterator(it_type from, ref_type ref) ENTT_NOEXCEPT
iterable_group_iterator(it_type from, ref_type ref) ENTT_NOEXCEPT
: it{from},
pools{ref}
{}
@@ -98,12 +98,12 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
));
using iterator_category = std::input_iterator_tag;
proxy_iterator & operator++() ENTT_NOEXCEPT {
iterable_group_iterator & operator++() ENTT_NOEXCEPT {
return ++it, *this;
}
proxy_iterator operator++(int) ENTT_NOEXCEPT {
proxy_iterator orig = *this;
iterable_group_iterator operator++(int) ENTT_NOEXCEPT {
iterable_group_iterator orig = *this;
return ++(*this), orig;
}
@@ -111,11 +111,11 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
return std::apply([entt = *it](auto *... cpool) { return reference{entt, cpool->get(entt)...}; }, pools);
}
[[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const iterable_group_iterator &other) const ENTT_NOEXCEPT {
return other.it == it;
}
[[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const iterable_group_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
@@ -124,16 +124,16 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
ref_type pools{};
};
group_proxy(const basic_sparse_set<Entity> &ref, std::tuple<pool_type<Get> *...> gpools)
iterable_group(const basic_sparse_set<Entity> &ref, std::tuple<pool_type<Get> *...> gpools)
: handler{&ref},
pools{gpools}
{}
public:
using iterator = proxy_iterator;
using iterator = iterable_group_iterator;
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
return proxy_iterator{handler->begin(), std::tuple_cat([](auto *cpool) {
return iterable_group_iterator{handler->begin(), std::tuple_cat([](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
return std::make_tuple();
} else {
@@ -143,7 +143,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
}
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
return proxy_iterator{handler->end(), std::tuple_cat([](auto *cpool) {
return iterable_group_iterator{handler->end(), std::tuple_cat([](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
return std::make_tuple();
} else {
@@ -469,8 +469,8 @@ public:
*
* @return An iterable object to use to _visit_ the group.
*/
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
return group_proxy{*handler, pools};
[[nodiscard]] auto each() const ENTT_NOEXCEPT {
return iterable_group{*handler, pools};
}
/**
@@ -609,17 +609,17 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
template<typename Component>
using component_iterator = decltype(std::declval<pool_type<Component>>().begin());
class group_proxy {
class iterable_group {
friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...>;
class proxy_iterator {
friend class group_proxy;
class iterable_group_iterator {
friend class iterable_group;
using it_type = typename basic_sparse_set<Entity>::iterator;
using owned_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Owned>, std::tuple<>, std::tuple<component_iterator<Owned>>>>()...));
using get_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Get>, std::tuple<>, std::tuple<pool_type<Get> *>>>()...));
proxy_iterator(it_type from, owned_type oref, get_type gref) ENTT_NOEXCEPT
iterable_group_iterator(it_type from, owned_type oref, get_type gref) ENTT_NOEXCEPT
: it{from},
owned{oref},
get{gref}
@@ -640,12 +640,12 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
));
using iterator_category = std::input_iterator_tag;
proxy_iterator & operator++() ENTT_NOEXCEPT {
iterable_group_iterator & operator++() ENTT_NOEXCEPT {
return ++it, std::apply([](auto &&... curr) { (++curr, ...); }, owned), *this;
}
proxy_iterator operator++(int) ENTT_NOEXCEPT {
proxy_iterator orig = *this;
iterable_group_iterator operator++(int) ENTT_NOEXCEPT {
iterable_group_iterator orig = *this;
return ++(*this), orig;
}
@@ -657,11 +657,11 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
);
}
[[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const iterable_group_iterator &other) const ENTT_NOEXCEPT {
return other.it == it;
}
[[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const iterable_group_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
@@ -671,16 +671,16 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
get_type get{};
};
group_proxy(std::tuple<pool_type<Owned> *..., pool_type<Get> *...> cpools, const std::size_t &extent)
iterable_group(std::tuple<pool_type<Owned> *..., pool_type<Get> *...> cpools, const std::size_t &extent)
: pools{cpools},
length{&extent}
{}
public:
using iterator = proxy_iterator;
using iterator = iterable_group_iterator;
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
return proxy_iterator{
return iterable_group_iterator{
std::get<0>(pools)->basic_sparse_set<Entity>::end() - *length,
std::tuple_cat([length = *length](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
@@ -700,7 +700,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
}
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
return proxy_iterator{
return iterable_group_iterator{
std::get<0>(pools)->basic_sparse_set<Entity>::end(),
std::tuple_cat([](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
@@ -1039,8 +1039,8 @@ public:
*
* @return An iterable object to use to _visit_ the group.
*/
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
return group_proxy{pools, *length};
[[nodiscard]] auto each() const ENTT_NOEXCEPT {
return iterable_group{pools, *length};
}
/**

View File

@@ -151,17 +151,17 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
filter_type filter;
};
class view_proxy {
class iterable_view {
friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;
using proxy_view_iterator = view_iterator<typename basic_sparse_set<Entity>::iterator>;
using underlying_iterator = view_iterator<typename basic_sparse_set<Entity>::iterator>;
class proxy_iterator {
friend class view_proxy;
class iterable_view_iterator {
friend class iterable_view;
using ref_type = decltype(std::tuple_cat(std::declval<std::conditional_t<is_eto_eligible_v<Component>, std::tuple<>, std::tuple<pool_type<Component> *>>>()...));
proxy_iterator(proxy_view_iterator from, ref_type ref) ENTT_NOEXCEPT
iterable_view_iterator(underlying_iterator from, ref_type ref) ENTT_NOEXCEPT
: it{from},
pools{ref}
{}
@@ -176,12 +176,12 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
using reference = value_type;
using iterator_category = std::input_iterator_tag;
proxy_iterator & operator++() ENTT_NOEXCEPT {
iterable_view_iterator & operator++() ENTT_NOEXCEPT {
return ++it, *this;
}
proxy_iterator operator++(int) ENTT_NOEXCEPT {
proxy_iterator orig = *this;
iterable_view_iterator operator++(int) ENTT_NOEXCEPT {
iterable_view_iterator orig = *this;
return ++(*this), orig;
}
@@ -189,30 +189,30 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
return std::apply([entt = *it](auto *... cpool) { return reference{entt, cpool->get(entt)...}; }, pools);
}
[[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const iterable_view_iterator &other) const ENTT_NOEXCEPT {
return other.it == it;
}
[[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const iterable_view_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
private:
proxy_view_iterator it{};
underlying_iterator it{};
const ref_type pools{};
};
view_proxy(proxy_view_iterator from, proxy_view_iterator to, std::tuple<pool_type<Component> *...> ref)
iterable_view(underlying_iterator from, underlying_iterator to, std::tuple<pool_type<Component> *...> ref)
: first{from},
last{to},
pools{ref}
{}
public:
using iterator = proxy_iterator;
using iterator = iterable_view_iterator;
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
return proxy_iterator{first, std::tuple_cat([](auto *cpool) {
return iterable_view_iterator{first, std::tuple_cat([](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
return std::make_tuple();
} else {
@@ -222,7 +222,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
}
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
return proxy_iterator{last, std::tuple_cat([](auto *cpool) {
return iterable_view_iterator{last, std::tuple_cat([](auto *cpool) {
if constexpr(is_eto_eligible_v<typename std::remove_reference_t<decltype(*cpool)>::value_type>) {
return std::make_tuple();
} else {
@@ -232,8 +232,8 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
}
private:
proxy_view_iterator first;
proxy_view_iterator last;
underlying_iterator first;
underlying_iterator last;
const std::tuple<pool_type<Component> *...> pools;
};
@@ -545,9 +545,9 @@ public:
*
* @return An iterable object to use to _visit_ the view.
*/
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
[[nodiscard]] auto each() const ENTT_NOEXCEPT {
view = candidate();
return view_proxy{begin(), end(), pools};
return iterable_view{begin(), end(), pools};
}
/**
@@ -565,11 +565,11 @@ public:
* @return An iterable object to use to _visit_ the view.
*/
template<typename Comp>
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
[[nodiscard]] auto each() const ENTT_NOEXCEPT {
const basic_sparse_set<entity_type> *cpool = std::get<pool_type<Comp> *>(pools);
iterator first{cpool->begin(), cpool->end(), cpool->begin(), unchecked(cpool), filter};
iterator last{cpool->begin(), cpool->end(), cpool->end(), unchecked(cpool), filter};
return view_proxy{std::move(first), std::move(last), pools};
return iterable_view{std::move(first), std::move(last), pools};
}
/**
@@ -656,11 +656,11 @@ class basic_view<Entity, exclude_t<>, Component> final {
using pool_type = pool_t<Entity, Component>;
class view_proxy {
class iterable_view {
friend class basic_view<Entity, exclude_t<>, Component>;
class proxy_iterator {
friend class view_proxy;
class iterable_view_iterator {
friend class iterable_view;
using it_type = std::conditional_t<
is_eto_eligible_v<Component>,
@@ -668,7 +668,7 @@ class basic_view<Entity, exclude_t<>, Component> final {
std::tuple<typename basic_sparse_set<Entity>::iterator, decltype(std::declval<pool_type>().begin())>
>;
proxy_iterator(it_type from) ENTT_NOEXCEPT
iterable_view_iterator(it_type from) ENTT_NOEXCEPT
: it{from}
{}
@@ -679,12 +679,12 @@ class basic_view<Entity, exclude_t<>, Component> final {
using reference = value_type;
using iterator_category = std::input_iterator_tag;
proxy_iterator & operator++() ENTT_NOEXCEPT {
iterable_view_iterator & operator++() ENTT_NOEXCEPT {
return std::apply([](auto &&... curr) { (++curr, ...); }, it), *this;
}
proxy_iterator operator++(int) ENTT_NOEXCEPT {
proxy_iterator orig = *this;
iterable_view_iterator operator++(int) ENTT_NOEXCEPT {
iterable_view_iterator orig = *this;
return ++(*this), orig;
}
@@ -692,11 +692,11 @@ class basic_view<Entity, exclude_t<>, Component> final {
return std::apply([](auto &&... curr) { return reference{*curr...}; }, it);
}
[[nodiscard]] bool operator==(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator==(const iterable_view_iterator &other) const ENTT_NOEXCEPT {
return std::get<0>(other.it) == std::get<0>(it);
}
[[nodiscard]] bool operator!=(const proxy_iterator &other) const ENTT_NOEXCEPT {
[[nodiscard]] bool operator!=(const iterable_view_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
@@ -704,26 +704,26 @@ class basic_view<Entity, exclude_t<>, Component> final {
it_type it{};
};
view_proxy(pool_type &ref)
iterable_view(pool_type &ref)
: pool{&ref}
{}
public:
using iterator = proxy_iterator;
using iterator = iterable_view_iterator;
[[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
if constexpr(is_eto_eligible_v<Component>) {
return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin())};
return iterable_view_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin())};
} else {
return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin(), pool->begin())};
return iterable_view_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::begin(), pool->begin())};
}
}
[[nodiscard]] iterator end() const ENTT_NOEXCEPT {
if constexpr(is_eto_eligible_v<Component>) {
return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end())};
return iterable_view_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end())};
} else {
return proxy_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end(), pool->end())};
return iterable_view_iterator{std::make_tuple(pool->basic_sparse_set<entity_type>::end(), pool->end())};
}
}
@@ -996,8 +996,8 @@ public:
*
* @return An iterable object to use to _visit_ the view.
*/
[[nodiscard]] auto proxy() const ENTT_NOEXCEPT {
return view_proxy{*pool};
[[nodiscard]] auto each() const ENTT_NOEXCEPT {
return iterable_view{*pool};
}
private:

View File

@@ -146,7 +146,7 @@ TEST(NonOwningGroup, Empty) {
ASSERT_TRUE(registry.group(entt::get<double, char, int, float>).empty());
}
TEST(NonOwningGroup, EachAndProxy) {
TEST(NonOwningGroup, Each) {
entt::registry registry;
auto group = registry.group(entt::get<int, char>);
@@ -164,7 +164,7 @@ TEST(NonOwningGroup, EachAndProxy) {
group.each([&cnt](auto, int &, char &) { ++cnt; });
group.each([&cnt](int &, char &) { ++cnt; });
for(auto &&[entt, iv, cv]: group.proxy()) {
for(auto &&[entt, iv, cv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -176,7 +176,7 @@ TEST(NonOwningGroup, EachAndProxy) {
cgroup.each([&cnt](auto, const int &, const char &) { --cnt; });
cgroup.each([&cnt](const int &, const char &) { --cnt; });
for(auto &&[entt, iv, cv]: cgroup.proxy()) {
for(auto &&[entt, iv, cv]: cgroup.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), const int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -321,7 +321,7 @@ TEST(NonOwningGroup, IndexRebuiltOnDestroy) {
ASSERT_EQ(uivalue, 1u);
});
for(auto &&curr: group.proxy()) {
for(auto &&curr: group.each()) {
ASSERT_EQ(std::get<0>(curr), e1);
ASSERT_EQ(std::get<1>(curr), 1);
ASSERT_EQ(std::get<2>(curr), 1u);
@@ -351,7 +351,7 @@ TEST(NonOwningGroup, ConstNonConstAndAllInBetween) {
static_assert(std::is_same_v<decltype(c), const char &>);
});
for(auto &&[entt, iv, cv]: group.proxy()) {
for(auto &&[entt, iv, cv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -473,7 +473,7 @@ TEST(NonOwningGroup, EmptyAndNonEmptyTypes) {
ASSERT_TRUE(entity == e0 || entity == e1);
});
for(auto &&[entt, iv]: group.proxy()) {
for(auto &&[entt, iv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
ASSERT_TRUE(entt == e0 || entt == e1);
@@ -512,7 +512,7 @@ TEST(NonOwningGroup, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.group(entt::get<int, char, empty_type>).proxy()) {
for(auto &&[entt, iv, cv]: registry.group(entt::get<int, char, empty_type>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -524,7 +524,7 @@ TEST(NonOwningGroup, EmptyTypes) {
check = false;
});
for(auto &&[entt, iv, cv]: registry.group(entt::get<int, empty_type, char>).proxy()) {
for(auto &&[entt, iv, cv]: registry.group(entt::get<int, empty_type, char>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -535,7 +535,7 @@ TEST(NonOwningGroup, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.group(entt::get<empty_type, int, char>).proxy()) {
for(auto &&[entt, iv, cv]: registry.group(entt::get<empty_type, int, char>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -543,7 +543,7 @@ TEST(NonOwningGroup, EmptyTypes) {
}
registry.group(entt::get<int, char, double>).each([](const auto, int, char, double) { FAIL(); });
ASSERT_EQ(registry.group(entt::get<int, char, double>).proxy().begin(), registry.group(entt::get<int, char, double>).proxy().end());
ASSERT_EQ(registry.group(entt::get<int, char, double>).each().begin(), registry.group(entt::get<int, char, double>).each().end());
}
TEST(NonOwningGroup, FrontBack) {
@@ -709,7 +709,7 @@ TEST(OwningGroup, Empty) {
ASSERT_TRUE((registry.group<double, float>(entt::get<char, int>).empty()));
}
TEST(OwningGroup, EachAndProxy) {
TEST(OwningGroup, Each) {
entt::registry registry;
auto group = registry.group<int>(entt::get<char>);
@@ -727,7 +727,7 @@ TEST(OwningGroup, EachAndProxy) {
group.each([&cnt](auto, int &, char &) { ++cnt; });
group.each([&cnt](int &, char &) { ++cnt; });
for(auto &&[entt, iv, cv]: group.proxy()) {
for(auto &&[entt, iv, cv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -739,7 +739,7 @@ TEST(OwningGroup, EachAndProxy) {
cgroup.each([&cnt](auto, const int &, const char &) { --cnt; });
cgroup.each([&cnt](const int &, const char &) { --cnt; });
for(auto &&[entt, iv, cv]: cgroup.proxy()) {
for(auto &&[entt, iv, cv]: cgroup.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), const int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -968,7 +968,7 @@ TEST(OwningGroup, IndexRebuiltOnDestroy) {
ASSERT_EQ(uivalue, 1u);
});
for(auto &&curr: group.proxy()) {
for(auto &&curr: group.each()) {
ASSERT_EQ(std::get<0>(curr), e1);
ASSERT_EQ(std::get<1>(curr), 1);
ASSERT_EQ(std::get<2>(curr), 1u);
@@ -1006,7 +1006,7 @@ TEST(OwningGroup, ConstNonConstAndAllInBetween) {
static_assert(std::is_same_v<decltype(f), const float &>);
});
for(auto &&[entt, iv, cv, dv, fv]: group.proxy()) {
for(auto &&[entt, iv, cv, dv, fv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -1130,7 +1130,7 @@ TEST(OwningGroup, EmptyAndNonEmptyTypes) {
ASSERT_TRUE(entity == e0 || entity == e1);
});
for(auto &&[entt, iv]: group.proxy()) {
for(auto &&[entt, iv]: group.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
ASSERT_TRUE(entt == e0 || entt == e1);
@@ -1169,7 +1169,7 @@ TEST(OwningGroup, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.group<int>(entt::get<char, empty_type>).proxy()) {
for(auto &&[entt, iv, cv]: registry.group<int>(entt::get<char, empty_type>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -1181,7 +1181,7 @@ TEST(OwningGroup, EmptyTypes) {
check = false;
});
for(auto &&[entt, cv, iv]: registry.group<char>(entt::get<empty_type, int>).proxy()) {
for(auto &&[entt, cv, iv]: registry.group<char>(entt::get<empty_type, int>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(cv), char &>);
static_assert(std::is_same_v<decltype(iv), int &>);
@@ -1192,7 +1192,7 @@ TEST(OwningGroup, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.group<empty_type>(entt::get<int, char>).proxy()) {
for(auto &&[entt, iv, cv]: registry.group<empty_type>(entt::get<int, char>).each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -1200,7 +1200,7 @@ TEST(OwningGroup, EmptyTypes) {
}
registry.group<double>(entt::get<int, char>).each([](const auto, double, int, char) { FAIL(); });
ASSERT_EQ(registry.group<double>(entt::get<int, char>).proxy().begin(), registry.group<double>(entt::get<int, char>).proxy().end());
ASSERT_EQ(registry.group<double>(entt::get<int, char>).each().begin(), registry.group<double>(entt::get<int, char>).each().end());
}
TEST(OwningGroup, FrontBack) {

View File

@@ -107,7 +107,7 @@ TEST(SingleComponentView, Empty) {
ASSERT_EQ(view.rbegin(), view.rend());
}
TEST(SingleComponentView, EachAndProxy) {
TEST(SingleComponentView, Each) {
entt::registry registry;
registry.emplace<int>(registry.create());
@@ -120,7 +120,7 @@ TEST(SingleComponentView, EachAndProxy) {
view.each([&cnt](auto, int &) { ++cnt; });
view.each([&cnt](int &) { ++cnt; });
for(auto &&[entt, iv]: view.proxy()) {
for(auto &&[entt, iv]: view.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
++cnt;
@@ -131,7 +131,7 @@ TEST(SingleComponentView, EachAndProxy) {
cview.each([&cnt](auto, const int &) { --cnt; });
cview.each([&cnt](const int &) { --cnt; });
for(auto &&[entt, iv]: cview.proxy()) {
for(auto &&[entt, iv]: cview.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), const int &>);
--cnt;
@@ -169,12 +169,12 @@ TEST(SingleComponentView, ConstNonConstAndAllInBetween) {
static_assert(std::is_same_v<decltype(i), const int &>);
});
for(auto &&[entt, iv]: view.proxy()) {
for(auto &&[entt, iv]: view.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
}
for(auto &&[entt, iv]: cview.proxy()) {
for(auto &&[entt, iv]: cview.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), const int &>);
}
@@ -240,7 +240,7 @@ TEST(SingleComponentView, EmptyTypes) {
check = false;
});
for(auto &&[entt]: registry.view<empty_type>().proxy()) {
for(auto &&[entt]: registry.view<empty_type>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
ASSERT_EQ(entity, entt);
}
@@ -254,7 +254,7 @@ TEST(SingleComponentView, EmptyTypes) {
check = false;
});
for(auto &&[entt, iv]: registry.view<int>().proxy()) {
for(auto &&[entt, iv]: registry.view<int>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
ASSERT_EQ(entity, entt);
@@ -411,7 +411,7 @@ TEST(MultiComponentView, Empty) {
ASSERT_EQ(view.rbegin(), view.rend());
}
TEST(MultiComponentView, EachAndProxy) {
TEST(MultiComponentView, Each) {
entt::registry registry;
const auto e0 = registry.create();
@@ -429,7 +429,7 @@ TEST(MultiComponentView, EachAndProxy) {
view.each([&cnt](auto, int &, char &) { ++cnt; });
view.each([&cnt](int &, char &) { ++cnt; });
for(auto &&[entt, iv, cv]: view.proxy()) {
for(auto &&[entt, iv, cv]: view.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -441,7 +441,7 @@ TEST(MultiComponentView, EachAndProxy) {
cview.each([&cnt](auto, const int &, const char &) { --cnt; });
cview.each([&cnt](const int &, const char &) { --cnt; });
for(auto &&[entt, iv, cv]: cview.proxy()) {
for(auto &&[entt, iv, cv]: cview.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), const int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -451,7 +451,7 @@ TEST(MultiComponentView, EachAndProxy) {
ASSERT_EQ(cnt, std::size_t{0});
}
TEST(MultiComponentView, EachAndProxyWithSuggestedType) {
TEST(MultiComponentView, EachWithSuggestedType) {
entt::registry registry;
for(auto i = 0; i < 3; ++i) {
@@ -482,7 +482,7 @@ TEST(MultiComponentView, EachAndProxyWithSuggestedType) {
auto value = registry.view<int, char>().size_hint();
for(auto &&curr: registry.view<int, char>().proxy()) {
for(auto &&curr: registry.view<int, char>().each()) {
ASSERT_EQ(std::get<1>(curr), static_cast<int>(--value));
}
@@ -492,12 +492,12 @@ TEST(MultiComponentView, EachAndProxyWithSuggestedType) {
value = {};
for(auto &&curr: registry.view<int, char>().proxy<int>()) {
for(auto &&curr: registry.view<int, char>().each<int>()) {
ASSERT_EQ(std::get<1>(curr), static_cast<int>(value++));
}
}
TEST(MultiComponentView, EachAndProxyWithHoles) {
TEST(MultiComponentView, EachWithHoles) {
entt::registry registry;
const auto e0 = registry.create();
@@ -518,7 +518,7 @@ TEST(MultiComponentView, EachAndProxyWithHoles) {
ASSERT_EQ(i, 0);
});
for(auto &&curr: view.proxy()) {
for(auto &&curr: view.each()) {
ASSERT_EQ(std::get<0>(curr), e0);
ASSERT_EQ(std::get<1>(curr), '0');
ASSERT_EQ(std::get<2>(curr), 0);
@@ -546,7 +546,7 @@ TEST(MultiComponentView, ConstNonConstAndAllInBetween) {
static_assert(std::is_same_v<decltype(c), const char &>);
});
for(auto &&[entt, iv, cv]: view.proxy()) {
for(auto &&[entt, iv, cv]: view.each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), const char &>);
@@ -660,7 +660,7 @@ TEST(MultiComponentView, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.view<int, char, empty_type>().proxy()) {
for(auto &&[entt, iv, cv]: registry.view<int, char, empty_type>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -672,7 +672,7 @@ TEST(MultiComponentView, EmptyTypes) {
check = false;
});
for(auto &&[entt, iv, cv]: registry.view<int, empty_type, char>().proxy()) {
for(auto &&[entt, iv, cv]: registry.view<int, empty_type, char>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -683,7 +683,7 @@ TEST(MultiComponentView, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.view<empty_type, int, char>().proxy()) {
for(auto &&[entt, iv, cv]: registry.view<empty_type, int, char>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -694,7 +694,7 @@ TEST(MultiComponentView, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv]: registry.view<empty_type, int, char>().proxy<empty_type>()) {
for(auto &&[entt, iv, cv]: registry.view<empty_type, int, char>().each<empty_type>()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -706,7 +706,7 @@ TEST(MultiComponentView, EmptyTypes) {
check = false;
});
for(auto &&[entt, iv, cv]: registry.view<int, empty_type, char>().proxy<empty_type>()) {
for(auto &&[entt, iv, cv]: registry.view<int, empty_type, char>().each<empty_type>()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);
@@ -717,7 +717,7 @@ TEST(MultiComponentView, EmptyTypes) {
ASSERT_EQ(entity, entt);
});
for(auto &&[entt, iv, cv, dv]: registry.view<int, char, double>().proxy()) {
for(auto &&[entt, iv, cv, dv]: registry.view<int, char, double>().each()) {
static_assert(std::is_same_v<decltype(entt), entt::entity>);
static_assert(std::is_same_v<decltype(iv), int &>);
static_assert(std::is_same_v<decltype(cv), char &>);