1#ifndef ENTT_META_RANGE_HPP
2#define ENTT_META_RANGE_HPP
7#include "../core/fwd.hpp"
8#include "../core/iterator.hpp"
18template<
typename Type,
typename It>
19struct meta_range_iterator final {
20 using value_type = std::pair<id_type, Type>;
21 using pointer = input_iterator_pointer<value_type>;
22 using reference = value_type;
23 using difference_type = std::ptrdiff_t;
24 using iterator_category = std::input_iterator_tag;
25 using iterator_concept = std::random_access_iterator_tag;
27 constexpr meta_range_iterator() noexcept
31 constexpr meta_range_iterator(
const meta_ctx &area,
const It iter) noexcept
35 constexpr meta_range_iterator &operator++() noexcept {
39 constexpr meta_range_iterator operator++(
int)
noexcept {
40 meta_range_iterator orig = *
this;
41 return ++(*this), orig;
44 constexpr meta_range_iterator &operator--() noexcept {
48 constexpr meta_range_iterator operator--(
int)
noexcept {
49 meta_range_iterator orig = *
this;
50 return operator--(), orig;
53 constexpr meta_range_iterator &operator+=(
const difference_type value)
noexcept {
58 constexpr meta_range_iterator
operator+(
const difference_type value)
const noexcept {
59 meta_range_iterator copy = *
this;
60 return (copy += value);
63 constexpr meta_range_iterator &operator-=(
const difference_type value)
noexcept {
64 return (*
this += -value);
67 constexpr meta_range_iterator operator-(
const difference_type value)
const noexcept {
68 return (*
this + -value);
71 [[nodiscard]]
constexpr reference operator[](
const difference_type value)
const noexcept {
72 if constexpr(std::is_same_v<It,
typename decltype(meta_context::value)::const_iterator>) {
73 return {it[value].first, Type{*ctx, it[value].second}};
74 }
else if constexpr(std::is_same_v<typename std::iterator_traits<It>::value_type, meta_base_node>) {
75 return {it[value].type, Type{*ctx, it[value]}};
77 return {it[value].id, Type{*ctx, it[value]}};
81 [[nodiscard]]
constexpr pointer operator->() const noexcept {
85 [[nodiscard]]
constexpr reference operator*() const noexcept {
89 template<
typename... Args>
90 friend constexpr std::ptrdiff_t operator-(
const meta_range_iterator<Args...> &,
const meta_range_iterator<Args...> &)
noexcept;
92 template<
typename... Args>
93 friend constexpr bool operator==(
const meta_range_iterator<Args...> &,
const meta_range_iterator<Args...> &)
noexcept;
95 template<
typename... Args>
96 friend constexpr bool operator<(
const meta_range_iterator<Args...> &,
const meta_range_iterator<Args...> &)
noexcept;
103template<
typename... Args>
104[[nodiscard]]
constexpr std::ptrdiff_t operator-(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
105 return lhs.it - rhs.it;
108template<
typename... Args>
109[[nodiscard]]
constexpr bool operator==(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
110 return lhs.it == rhs.it;
113template<
typename... Args>
114[[nodiscard]]
constexpr bool operator!=(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
115 return !(lhs == rhs);
118template<
typename... Args>
119[[nodiscard]]
constexpr bool operator<(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
120 return lhs.it < rhs.it;
123template<
typename... Args>
124[[nodiscard]]
constexpr bool operator>(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
128template<
typename... Args>
129[[nodiscard]]
constexpr bool operator<=(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
133template<
typename... Args>
134[[nodiscard]]
constexpr bool operator>=(
const meta_range_iterator<Args...> &lhs,
const meta_range_iterator<Args...> &rhs)
noexcept {
146template<
typename Type,
typename It>
constexpr bool operator<=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator<(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr type_list< Type..., Other... > operator+(type_list< Type... >, type_list< Other... >)
Concatenates multiple type lists.
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator>=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator>(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator==(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
Utility class to create an iterable object from a pair of iterators.