1#ifndef HALCHECK_LIB_ITERATOR_INDEX_HPP
2#define HALCHECK_LIB_ITERATOR_INDEX_HPP
6#include <halcheck/lib/iterator/interface.hpp>
7#include <halcheck/lib/iterator/range.hpp>
8#include <halcheck/lib/pp.hpp>
9#include <halcheck/lib/type_traits.hpp>
13namespace halcheck {
namespace lib {
77 template<typename T, HALCHECK_REQUIRE(std::is_convertible<T *, R *>())>
79 : _base(other._base), _index(other._index) {}
134 return lhs._index - rhs._index;
friend difference_type operator-(const index_iterator &lhs, const index_iterator &rhs)
Computes the distance between two iterators.
Definition index.hpp:133
index_iterator(R &base, difference_type index=0)
Constructs an index_iterator pointing into the given range.
Definition index.hpp:69
difference_type index() const
Gets the index of the element this iterator points to.
Definition index.hpp:118
index_iterator & operator+=(difference_type n)
Advances this iterator by the specified number of steps.
Definition index.hpp:109
index_iterator(const index_iterator< T > &other)
Converts between index_iterators.
Definition index.hpp:78
index_iterator & operator--()
Advances this iterator backwards.
Definition index.hpp:100
index_iterator & operator++()
Advances this iterator.
Definition index.hpp:91
friend bool operator==(const index_iterator &lhs, const index_iterator &rhs)
Determines if two iterators are equal.
Definition index.hpp:126
reference operator*() const
Obtains the element this iterator points to.
Definition index.hpp:85
An iterator into a random-access range that is invalidated if and only if the index of the pointed-to...
Definition index.hpp:22
index_iterator()=default
Constructs a default index_iterator.
lib::range_reference_t< R > reference
The type of value returned by operator*.
Definition index.hpp:42
lib::range_value_t< R > value_type
The type of value this iterator points to.
Definition index.hpp:37
lib::range_difference_t< R > difference_type
The type of distances between iterators.
Definition index.hpp:52
void pointer
This iterator does not support operator->.
Definition index.hpp:47
A utility class for easily defining new iterators.
Definition interface.hpp:40
lib::iter_value_t< lib::iterator_t< R > > range_value_t
The type of element contained in a range.
Definition range.hpp:332
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@22 make_index_iterator
Constructs an index_iterator.
lib::iter_reference_t< lib::iterator_t< R > > range_reference_t
The type returned by operator* for a range type's iterators.
Definition range.hpp:340
lib::iter_difference_t< lib::iterator_t< R > > range_difference_t
The type of value returned by operator- for a range type's iterators.
Definition range.hpp:324
#define HALCHECK_INLINE_CONSTEXPR
A backwards-compatible substitute for inline constexpr.
Definition pp.hpp:70
Determines whether a type is a range whose iterators satisfy lib::is_random_access_iterator.
Definition range.hpp:219