iterators: standard-ish names for better integration

This commit is contained in:
Michele Caini
2020-03-30 16:11:10 +02:00
parent 86a392991a
commit 92cf6195b2
10 changed files with 144 additions and 144 deletions

View File

@@ -94,7 +94,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;
using iterator = typename sparse_set<Entity>::iterator;
/**
* @brief Returns the number of existing components of the given type.
@@ -210,7 +210,7 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const ENTT_NOEXCEPT {
iterator begin() const ENTT_NOEXCEPT {
return handler->begin();
}
@@ -229,7 +229,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const ENTT_NOEXCEPT {
iterator end() const ENTT_NOEXCEPT {
return handler->end();
}
@@ -259,7 +259,7 @@ public:
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entt) const {
iterator find(const entity_type entt) const {
const auto it = handler->find(entt);
return it != end() && *it == entt ? it : end();
}
@@ -505,7 +505,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> {
using pool_type = std::conditional_t<std::is_const_v<Component>, const storage<Entity, std::remove_const_t<Component>>, storage<Entity, Component>>;
template<typename Component>
using component_iterator_type = decltype(std::declval<pool_type<Component>>().begin());
using component_iterator = decltype(std::declval<pool_type<Component>>().begin());
// we could use pool_type<Type> &..., but vs complains about it and refuses to compile for unknown reasons (most likely a bug)
basic_group(const std::size_t &ref, const std::size_t &extent, storage<Entity, std::remove_const_t<Owned>> &... opool, storage<Entity, std::remove_const_t<Get>> &... gpool) ENTT_NOEXCEPT
@@ -522,14 +522,14 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> {
for(auto next = *length; next; --next) {
if constexpr(std::is_invocable_v<Func, decltype(get<Strong>({}))..., decltype(get<Weak>({}))...>) {
if constexpr(sizeof...(Weak) == 0) {
func(*(std::get<component_iterator_type<Strong>>(it)++)...);
func(*(std::get<component_iterator<Strong>>(it)++)...);
} else {
const auto entt = *(data++);
func(*(std::get<component_iterator_type<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
func(*(std::get<component_iterator<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
}
} else {
const auto entt = *(data++);
func(entt, *(std::get<component_iterator_type<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
func(entt, *(std::get<component_iterator<Strong>>(it)++)..., std::get<pool_type<Weak> *>(pools)->get(entt)...);
}
}
}
@@ -540,7 +540,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;
using iterator = typename sparse_set<Entity>::iterator;
/**
* @brief Returns the number of existing components of the given type.
@@ -648,7 +648,7 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const ENTT_NOEXCEPT {
iterator begin() const ENTT_NOEXCEPT {
return std::get<0>(pools)->sparse_set<entity_type>::end() - *length;
}
@@ -667,7 +667,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const ENTT_NOEXCEPT {
iterator end() const ENTT_NOEXCEPT {
return std::get<0>(pools)->sparse_set<entity_type>::end();
}
@@ -697,7 +697,7 @@ public:
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entt) const {
iterator find(const entity_type entt) const {
const auto it = std::get<0>(pools)->find(entt);
return it != end() && it >= begin() && *it == entt ? it : end();
}

View File

@@ -268,7 +268,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;
using iterator = typename sparse_set<Entity>::iterator;
/*! @brief Default constructor. */
basic_observer()
@@ -370,7 +370,7 @@ public:
*
* @return An iterator to the first entity of the observer.
*/
iterator_type begin() const ENTT_NOEXCEPT {
iterator begin() const ENTT_NOEXCEPT {
return view.sparse_set<entity_type>::begin();
}
@@ -384,7 +384,7 @@ public:
* @return An iterator to the entity following the last entity of the
* observer.
*/
iterator_type end() const ENTT_NOEXCEPT {
iterator end() const ENTT_NOEXCEPT {
return view.sparse_set<entity_type>::end();
}

View File

@@ -58,14 +58,14 @@ class basic_runtime_view {
/*! @brief A registry is allowed to create views. */
friend class basic_registry<Entity>;
using underlying_iterator_type = typename sparse_set<Entity>::iterator_type;
using underlying_iterator = typename sparse_set<Entity>::iterator;
class iterator final {
class view_iterator final {
friend class basic_runtime_view<Entity>;
using direct_type = std::vector<const sparse_set<Entity> *>;
iterator(const direct_type &all, underlying_iterator_type curr) ENTT_NOEXCEPT
view_iterator(const direct_type &all, underlying_iterator curr) ENTT_NOEXCEPT
: pools{&all},
it{curr}
{
@@ -81,39 +81,39 @@ class basic_runtime_view {
}
public:
using difference_type = typename underlying_iterator_type::difference_type;
using value_type = typename underlying_iterator_type::value_type;
using pointer = typename underlying_iterator_type::pointer;
using reference = typename underlying_iterator_type::reference;
using difference_type = typename underlying_iterator::difference_type;
using value_type = typename underlying_iterator::value_type;
using pointer = typename underlying_iterator::pointer;
using reference = typename underlying_iterator::reference;
using iterator_category = std::bidirectional_iterator_tag;
iterator() ENTT_NOEXCEPT = default;
view_iterator() ENTT_NOEXCEPT = default;
iterator & operator++() {
view_iterator & operator++() {
while(++it != (*pools)[0]->end() && !valid());
return *this;
}
iterator operator++(int) {
iterator orig = *this;
view_iterator operator++(int) {
view_iterator orig = *this;
return operator++(), orig;
}
iterator & operator--() ENTT_NOEXCEPT {
view_iterator & operator--() ENTT_NOEXCEPT {
while(--it != (*pools)[0]->begin() && !valid());
return *this;
}
iterator operator--(int) ENTT_NOEXCEPT {
iterator orig = *this;
view_iterator operator--(int) ENTT_NOEXCEPT {
view_iterator orig = *this;
return operator--(), orig;
}
bool operator==(const iterator &other) const ENTT_NOEXCEPT {
bool operator==(const view_iterator &other) const ENTT_NOEXCEPT {
return other.it == it;
}
bool operator!=(const iterator &other) const ENTT_NOEXCEPT {
bool operator!=(const view_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
@@ -127,7 +127,7 @@ class basic_runtime_view {
private:
const direct_type *pools;
underlying_iterator_type it;
underlying_iterator it;
};
basic_runtime_view(std::vector<const sparse_set<Entity> *> others) ENTT_NOEXCEPT
@@ -151,7 +151,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = iterator;
using iterator = view_iterator;
/**
* @brief Estimates the number of entities that have the given components.
@@ -183,8 +183,8 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const {
iterator_type it{};
iterator begin() const {
iterator it{};
if(valid()) {
it = { pools, pools[0]->begin() };
@@ -208,8 +208,8 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const {
iterator_type it{};
iterator end() const {
iterator it{};
if(valid()) {
it = { pools, pools[0]->end() };

View File

@@ -52,13 +52,13 @@ class sparse_set {
static_assert(ENTT_PAGE_SIZE && ((ENTT_PAGE_SIZE & (ENTT_PAGE_SIZE - 1)) == 0));
static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(typename traits_type::entity_type);
class iterator final {
class sparse_set_iterator final {
friend class sparse_set<Entity>;
using direct_type = std::vector<Entity>;
using index_type = typename traits_type::difference_type;
iterator(const direct_type &ref, const index_type idx) ENTT_NOEXCEPT
sparse_set_iterator(const direct_type &ref, const index_type idx) ENTT_NOEXCEPT
: direct{&ref}, index{idx}
{}
@@ -69,45 +69,45 @@ class sparse_set {
using reference = const value_type &;
using iterator_category = std::random_access_iterator_tag;
iterator() ENTT_NOEXCEPT = default;
sparse_set_iterator() ENTT_NOEXCEPT = default;
iterator & operator++() ENTT_NOEXCEPT {
sparse_set_iterator & operator++() ENTT_NOEXCEPT {
return --index, *this;
}
iterator operator++(int) ENTT_NOEXCEPT {
sparse_set_iterator operator++(int) ENTT_NOEXCEPT {
iterator orig = *this;
return operator++(), orig;
}
iterator & operator--() ENTT_NOEXCEPT {
sparse_set_iterator & operator--() ENTT_NOEXCEPT {
return ++index, *this;
}
iterator operator--(int) ENTT_NOEXCEPT {
iterator orig = *this;
sparse_set_iterator operator--(int) ENTT_NOEXCEPT {
sparse_set_iterator orig = *this;
return operator--(), orig;
}
iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
sparse_set_iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
index -= value;
return *this;
}
iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
iterator copy = *this;
sparse_set_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
sparse_set_iterator copy = *this;
return (copy += value);
}
iterator & operator-=(const difference_type value) ENTT_NOEXCEPT {
sparse_set_iterator & operator-=(const difference_type value) ENTT_NOEXCEPT {
return (*this += -value);
}
iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
sparse_set_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
return (*this + -value);
}
difference_type operator-(const iterator &other) const ENTT_NOEXCEPT {
difference_type operator-(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return other.index - index;
}
@@ -116,27 +116,27 @@ class sparse_set {
return (*direct)[pos];
}
bool operator==(const iterator &other) const ENTT_NOEXCEPT {
bool operator==(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return other.index == index;
}
bool operator!=(const iterator &other) const ENTT_NOEXCEPT {
bool operator!=(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
bool operator<(const iterator &other) const ENTT_NOEXCEPT {
bool operator<(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return index > other.index;
}
bool operator>(const iterator &other) const ENTT_NOEXCEPT {
bool operator>(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return index < other.index;
}
bool operator<=(const iterator &other) const ENTT_NOEXCEPT {
bool operator<=(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return !(*this > other);
}
bool operator>=(const iterator &other) const ENTT_NOEXCEPT {
bool operator>=(const sparse_set_iterator &other) const ENTT_NOEXCEPT {
return !(*this < other);
}
@@ -182,7 +182,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Random access iterator type. */
using iterator_type = iterator;
using iterator = sparse_set_iterator;
/*! @brief Default constructor. */
sparse_set() = default;
@@ -296,9 +296,9 @@ public:
*
* @return An iterator to the first entity of the internal packed array.
*/
iterator_type begin() const ENTT_NOEXCEPT {
iterator begin() const ENTT_NOEXCEPT {
const typename traits_type::difference_type pos = direct.size();
return iterator_type{direct, pos};
return iterator{direct, pos};
}
/**
@@ -315,8 +315,8 @@ public:
* @return An iterator to the element following the last entity of the
* internal packed array.
*/
iterator_type end() const ENTT_NOEXCEPT {
return iterator_type{direct, {}};
iterator end() const ENTT_NOEXCEPT {
return iterator{direct, {}};
}
/**
@@ -325,7 +325,7 @@ public:
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entt) const {
iterator find(const entity_type entt) const {
return has(entt) ? --(end() - index(entt)) : end();
}
@@ -493,7 +493,7 @@ public:
* @param args Arguments to forward to the sort function object, if any.
*/
template<typename Compare, typename Sort = std_sort, typename... Args>
void sort(iterator_type first, iterator_type last, Compare compare, Sort algo = Sort{}, Args &&... args) {
void sort(iterator first, iterator last, Compare compare, Sort algo = Sort{}, Args &&... args) {
ENTT_ASSERT(!(last < first));
ENTT_ASSERT(!(last > end()));
@@ -537,7 +537,7 @@ public:
* @param args Arguments to forward to the sort function object, if any.
*/
template<typename Apply, typename Compare, typename Sort = std_sort, typename... Args>
void arrange(iterator_type first, iterator_type last, Apply apply, Compare compare, Sort algo = Sort{}, Args &&... args) {
void arrange(iterator first, iterator last, Apply apply, Compare compare, Sort algo = Sort{}, Args &&... args) {
ENTT_ASSERT(!(last < first));
ENTT_ASSERT(!(last > end()));

View File

@@ -51,13 +51,13 @@ class storage: public sparse_set<Entity> {
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
template<bool Const>
class iterator final {
class storage_iterator final {
friend class storage<Entity, Type>;
using instance_type = std::conditional_t<Const, const std::vector<Type>, std::vector<Type>>;
using index_type = typename traits_type::difference_type;
iterator(instance_type &ref, const index_type idx) ENTT_NOEXCEPT
storage_iterator(instance_type &ref, const index_type idx) ENTT_NOEXCEPT
: instances{&ref}, index{idx}
{}
@@ -68,45 +68,45 @@ class storage: public sparse_set<Entity> {
using reference = std::conditional_t<Const, const value_type &, value_type &>;
using iterator_category = std::random_access_iterator_tag;
iterator() ENTT_NOEXCEPT = default;
storage_iterator() ENTT_NOEXCEPT = default;
iterator & operator++() ENTT_NOEXCEPT {
storage_iterator & operator++() ENTT_NOEXCEPT {
return --index, *this;
}
iterator operator++(int) ENTT_NOEXCEPT {
iterator orig = *this;
storage_iterator operator++(int) ENTT_NOEXCEPT {
storage_iterator orig = *this;
return operator++(), orig;
}
iterator & operator--() ENTT_NOEXCEPT {
storage_iterator & operator--() ENTT_NOEXCEPT {
return ++index, *this;
}
iterator operator--(int) ENTT_NOEXCEPT {
iterator orig = *this;
storage_iterator operator--(int) ENTT_NOEXCEPT {
storage_iterator orig = *this;
return operator--(), orig;
}
iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
storage_iterator & operator+=(const difference_type value) ENTT_NOEXCEPT {
index -= value;
return *this;
}
iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
iterator copy = *this;
storage_iterator operator+(const difference_type value) const ENTT_NOEXCEPT {
storage_iterator copy = *this;
return (copy += value);
}
iterator & operator-=(const difference_type value) ENTT_NOEXCEPT {
storage_iterator & operator-=(const difference_type value) ENTT_NOEXCEPT {
return (*this += -value);
}
iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
storage_iterator operator-(const difference_type value) const ENTT_NOEXCEPT {
return (*this + -value);
}
difference_type operator-(const iterator &other) const ENTT_NOEXCEPT {
difference_type operator-(const storage_iterator &other) const ENTT_NOEXCEPT {
return other.index - index;
}
@@ -115,27 +115,27 @@ class storage: public sparse_set<Entity> {
return (*instances)[pos];
}
bool operator==(const iterator &other) const ENTT_NOEXCEPT {
bool operator==(const storage_iterator &other) const ENTT_NOEXCEPT {
return other.index == index;
}
bool operator!=(const iterator &other) const ENTT_NOEXCEPT {
bool operator!=(const storage_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
bool operator<(const iterator &other) const ENTT_NOEXCEPT {
bool operator<(const storage_iterator &other) const ENTT_NOEXCEPT {
return index > other.index;
}
bool operator>(const iterator &other) const ENTT_NOEXCEPT {
bool operator>(const storage_iterator &other) const ENTT_NOEXCEPT {
return index < other.index;
}
bool operator<=(const iterator &other) const ENTT_NOEXCEPT {
bool operator<=(const storage_iterator &other) const ENTT_NOEXCEPT {
return !(*this > other);
}
bool operator>=(const iterator &other) const ENTT_NOEXCEPT {
bool operator>=(const storage_iterator &other) const ENTT_NOEXCEPT {
return !(*this < other);
}
@@ -161,9 +161,9 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Random access iterator type. */
using iterator_type = iterator<false>;
using iterator = storage_iterator<false>;
/*! @brief Constant random access iterator type. */
using const_iterator_type = iterator<true>;
using const_iterator = storage_iterator<true>;
/**
* @brief Increases the capacity of a storage.
@@ -220,20 +220,20 @@ public:
*
* @return An iterator to the first instance of the given type.
*/
const_iterator_type cbegin() const ENTT_NOEXCEPT {
const_iterator cbegin() const ENTT_NOEXCEPT {
const typename traits_type::difference_type pos = underlying_type::size();
return const_iterator_type{instances, pos};
return const_iterator{instances, pos};
}
/*! @copydoc cbegin */
const_iterator_type begin() const ENTT_NOEXCEPT {
const_iterator begin() const ENTT_NOEXCEPT {
return cbegin();
}
/*! @copydoc begin */
iterator_type begin() ENTT_NOEXCEPT {
iterator begin() ENTT_NOEXCEPT {
const typename traits_type::difference_type pos = underlying_type::size();
return iterator_type{instances, pos};
return iterator{instances, pos};
}
/**
@@ -250,18 +250,18 @@ public:
* @return An iterator to the element following the last instance of the
* given type.
*/
const_iterator_type cend() const ENTT_NOEXCEPT {
return const_iterator_type{instances, {}};
const_iterator cend() const ENTT_NOEXCEPT {
return const_iterator{instances, {}};
}
/*! @copydoc cend */
const_iterator_type end() const ENTT_NOEXCEPT {
const_iterator end() const ENTT_NOEXCEPT {
return cend();
}
/*! @copydoc end */
iterator_type end() ENTT_NOEXCEPT {
return iterator_type{instances, {}};
iterator end() ENTT_NOEXCEPT {
return iterator{instances, {}};
}
/**
@@ -474,7 +474,7 @@ public:
* @param args Arguments to forward to the sort function object, if any.
*/
template<typename Compare, typename Sort = std_sort, typename... Args>
void sort(iterator_type first, iterator_type last, Compare compare, Sort algo = Sort{}, Args &&... args) {
void sort(iterator first, iterator last, Compare compare, Sort algo = Sort{}, Args &&... args) {
ENTT_ASSERT(!(last < first));
ENTT_ASSERT(!(last > end()));

View File

@@ -72,16 +72,16 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
using pool_type = std::conditional_t<std::is_const_v<Comp>, const storage<Entity, std::remove_const_t<Comp>>, storage<Entity, Comp>>;
template<typename Comp>
using component_iterator_type = decltype(std::declval<pool_type<Comp>>().begin());
using component_iterator = decltype(std::declval<pool_type<Comp>>().begin());
using underlying_iterator_type = typename sparse_set<Entity>::iterator_type;
using underlying_iterator = typename sparse_set<Entity>::iterator;
using unchecked_type = std::array<const sparse_set<Entity> *, (sizeof...(Component) - 1)>;
using filter_type = std::array<const sparse_set<Entity> *, sizeof...(Exclude)>;
class iterator final {
class view_iterator final {
friend class basic_view<Entity, exclude_t<Exclude...>, Component...>;
iterator(const sparse_set<Entity> &candidate, unchecked_type other, filter_type ignore, underlying_iterator_type curr) ENTT_NOEXCEPT
view_iterator(const sparse_set<Entity> &candidate, unchecked_type other, filter_type ignore, underlying_iterator curr) ENTT_NOEXCEPT
: view{&candidate},
unchecked{other},
filter{ignore},
@@ -98,39 +98,39 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
}
public:
using difference_type = typename underlying_iterator_type::difference_type;
using value_type = typename underlying_iterator_type::value_type;
using pointer = typename underlying_iterator_type::pointer;
using reference = typename underlying_iterator_type::reference;
using difference_type = typename underlying_iterator::difference_type;
using value_type = typename underlying_iterator::value_type;
using pointer = typename underlying_iterator::pointer;
using reference = typename underlying_iterator::reference;
using iterator_category = std::bidirectional_iterator_tag;
iterator() ENTT_NOEXCEPT = default;
view_iterator() ENTT_NOEXCEPT = default;
iterator & operator++() {
view_iterator & operator++() {
while(++it != view->end() && !valid());
return *this;
}
iterator operator++(int) {
iterator orig = *this;
view_iterator operator++(int) {
view_iterator orig = *this;
return operator++(), orig;
}
iterator & operator--() ENTT_NOEXCEPT {
view_iterator & operator--() ENTT_NOEXCEPT {
while(--it != view->begin() && !valid());
return *this;
}
iterator operator--(int) ENTT_NOEXCEPT {
iterator orig = *this;
view_iterator operator--(int) ENTT_NOEXCEPT {
view_iterator orig = *this;
return operator--(), orig;
}
bool operator==(const iterator &other) const ENTT_NOEXCEPT {
bool operator==(const view_iterator &other) const ENTT_NOEXCEPT {
return other.it == it;
}
bool operator!=(const iterator &other) const ENTT_NOEXCEPT {
bool operator!=(const view_iterator &other) const ENTT_NOEXCEPT {
return !(*this == other);
}
@@ -146,7 +146,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
const sparse_set<Entity> *view;
unchecked_type unchecked;
filter_type filter;
underlying_iterator_type it;
underlying_iterator it;
};
// we could use pool_type<Component> &..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
@@ -168,7 +168,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
}
template<typename Comp, typename Other>
decltype(auto) get([[maybe_unused]] component_iterator_type<Comp> it, [[maybe_unused]] pool_type<Other> *cpool, [[maybe_unused]] const Entity entt) const {
decltype(auto) get([[maybe_unused]] component_iterator<Comp> it, [[maybe_unused]] pool_type<Other> *cpool, [[maybe_unused]] const Entity entt) const {
if constexpr(std::is_same_v<Comp, Other>) {
return *it;
} else {
@@ -211,7 +211,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = iterator;
using iterator = view_iterator;
/**
* @brief Returns the number of existing components of the given type.
@@ -305,10 +305,10 @@ public:
*
* @return An iterator to the first entity that has the given components.
*/
iterator_type begin() const {
iterator begin() const {
const auto &view = candidate();
const filter_type ignore{std::get<pool_type<Exclude> *>(pools)...};
return iterator_type{view, unchecked(view), ignore, view.begin()};
return iterator{view, unchecked(view), ignore, view.begin()};
}
/**
@@ -326,10 +326,10 @@ public:
* @return An iterator to the entity following the last entity that has the
* given components.
*/
iterator_type end() const {
iterator end() const {
const auto &view = candidate();
const filter_type ignore{std::get<pool_type<Exclude> *>(pools)...};
return iterator_type{view, unchecked(view), ignore, view.end()};
return iterator{view, unchecked(view), ignore, view.end()};
}
/**
@@ -358,10 +358,10 @@ public:
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entt) const {
iterator find(const entity_type entt) const {
const auto &view = candidate();
const filter_type ignore{std::get<pool_type<Exclude> *>(pools)...};
iterator_type it{view, unchecked(view), ignore, view.find(entt)};
iterator it{view, unchecked(view), ignore, view.find(entt)};
return (it != end() && *it == entt) ? it : end();
}
@@ -561,7 +561,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Input iterator type. */
using iterator_type = typename sparse_set<Entity>::iterator_type;
using iterator = typename sparse_set<Entity>::iterator;
/**
* @brief Returns the number of entities that have the given component.
@@ -625,7 +625,7 @@ public:
*
* @return An iterator to the first entity that has the given component.
*/
iterator_type begin() const ENTT_NOEXCEPT {
iterator begin() const ENTT_NOEXCEPT {
return pool->sparse_set<Entity>::begin();
}
@@ -644,7 +644,7 @@ public:
* @return An iterator to the entity following the last entity that has the
* given component.
*/
iterator_type end() const ENTT_NOEXCEPT {
iterator end() const ENTT_NOEXCEPT {
return pool->sparse_set<Entity>::end();
}
@@ -674,7 +674,7 @@ public:
* @return An iterator to the given entity if it's found, past the end
* iterator otherwise.
*/
iterator_type find(const entity_type entt) const {
iterator find(const entity_type entt) const {
const auto it = pool->find(entt);
return it != end() && *it == entt ? it : end();
}

View File

@@ -57,10 +57,10 @@ TEST(RuntimeView, Iterator) {
ENTT_ID_TYPE types[] = { entt::type_info<int>::id(), entt::type_info<char>::id() };
auto view = registry.runtime_view(std::begin(types), std::end(types));
using iterator_type = typename decltype(view)::iterator_type;
using iterator = typename decltype(view)::iterator;
iterator_type end{view.begin()};
iterator_type begin{};
iterator end{view.begin()};
iterator begin{};
begin = view.end();
std::swap(begin, end);

View File

@@ -139,13 +139,13 @@ TEST(SparseSet, BatchAdd) {
}
TEST(SparseSet, Iterator) {
using iterator_type = typename entt::sparse_set<entt::entity>::iterator_type;
using iterator = typename entt::sparse_set<entt::entity>::iterator;
entt::sparse_set<entt::entity> set;
set.construct(entt::entity{3});
iterator_type end{set.begin()};
iterator_type begin{};
iterator end{set.begin()};
iterator begin{};
begin = set.end();
std::swap(begin, end);

View File

@@ -135,13 +135,13 @@ TEST(Storage, TypesFromStandardTemplateLibraryMustWork) {
}
TEST(Storage, Iterator) {
using iterator_type = typename entt::storage<entt::entity, boxed_int>::iterator_type;
using iterator = typename entt::storage<entt::entity, boxed_int>::iterator;
entt::storage<entt::entity, boxed_int> pool;
pool.construct(entt::entity{3}, 42);
iterator_type end{pool.begin()};
iterator_type begin{};
iterator end{pool.begin()};
iterator begin{};
begin = pool.end();
std::swap(begin, end);
@@ -177,13 +177,13 @@ TEST(Storage, Iterator) {
}
TEST(Storage, ConstIterator) {
using iterator_type = typename entt::storage<entt::entity, boxed_int>::const_iterator_type;
using iterator = typename entt::storage<entt::entity, boxed_int>::const_iterator;
entt::storage<entt::entity, boxed_int> pool;
pool.construct(entt::entity{3}, 42);
iterator_type cend{pool.cbegin()};
iterator_type cbegin{};
iterator cend{pool.cbegin()};
iterator cbegin{};
cbegin = pool.cend();
std::swap(cbegin, cend);

View File

@@ -298,10 +298,10 @@ TEST(MultiComponentView, Iterator) {
registry.assign<char>(entity);
const auto view = registry.view<int, char>();
using iterator_type = typename decltype(view)::iterator_type;
using iterator = typename decltype(view)::iterator;
iterator_type end{view.begin()};
iterator_type begin{};
iterator end{view.begin()};
iterator begin{};
begin = view.end();
std::swap(begin, end);