5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MOVE_ITERATOR_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_MOVE_ITERATOR_HPP_
16#include "arene/base/constraints.hpp"
17#include "arene/base/iterator.hpp"
18#include "arene/base/type_traits/iterator_category_traits.hpp"
19#include "stdlib/include/stdlib_detail/conditional.hpp"
20#include "stdlib/include/stdlib_detail/enable_if.hpp"
21#include "stdlib/include/stdlib_detail/is_assignable.hpp"
22#include "stdlib/include/stdlib_detail/is_copy_constructible.hpp"
23#include "stdlib/include/stdlib_detail/is_default_constructible.hpp"
24#include "stdlib/include/stdlib_detail/is_reference.hpp"
25#include "stdlib/include/stdlib_detail/iterator_traits.hpp"
26#include "stdlib/include/stdlib_detail/remove_reference.hpp"
34template <
typename Iterator>
38 "The underlying iterator must be at least an input iterator"
48 using iterator_type = Iterator;
52 using pointer = Iterator;
69 typename SfinaeIterator = Iterator,
70 arene::base::constraints<enable_if_t<is_default_constructible_v<SfinaeIterator>>> =
nullptr>
97 typename OtherIterator,
98 arene::base::constraints<enable_if_t<is_convertible_v<OtherIterator, Iterator>>> =
nullptr>
101 : current_(source.base()) {}
110 typename OtherIterator,
111 arene::base::constraints<enable_if_t<is_convertible_v<OtherIterator, Iterator>>> =
nullptr>
113 current_ = source.base();
119 auto base()
const -> iterator_type {
return current_; }
130 auto operator->()
const -> pointer {
return current_; }
135 arene::base::advance(current_, 1);
143 arene::base::advance(current_, 1);
153 arene::base::is_bidirectional_iterator_v<Iterator>,
154 "The underlying iterator must be at least a bidirectional iterator to decrement"
156 arene::base::advance(current_, -1);
165 arene::base::is_bidirectional_iterator_v<Iterator>,
166 "The underlying iterator must be at least a bidirectional iterator to decrement"
169 arene::base::advance(current_, -1);
182 arene::base::is_random_access_iterator_v<Iterator>,
183 "The underlying iterator must be at least a random access iterator for random access operations"
196 arene::base::is_random_access_iterator_v<Iterator>,
197 "The underlying iterator must be at least a random access iterator for random access operations"
199 arene::base::advance(current_, delta);
210 arene::base::is_random_access_iterator_v<Iterator>,
211 "The underlying iterator must be at least a random access iterator for random access operations"
224 arene::base::is_random_access_iterator_v<Iterator>,
225 "The underlying iterator must be at least a random access iterator for random access operations"
227 arene::base::advance(current_, -delta);
239 arene::base::is_random_access_iterator_v<Iterator>,
240 "The underlying iterator must be at least a random access iterator for random access operations"
243 return static_cast<reference>(current_[delta]);
257template <
typename Iterator1,
typename Iterator2>
259 return lhs.base() == rhs.base();
270template <
typename Iterator1,
typename Iterator2>
272 return !(lhs == rhs);
282template <
typename Iterator1,
typename Iterator2>
284 return lhs.base() < rhs.base();
293template <
typename Iterator1,
typename Iterator2>
304template <
typename Iterator1,
typename Iterator2>
315template <
typename Iterator1,
typename Iterator2>
329template <
typename Iterator1,
typename Iterator2>
331 ->
decltype(lhs.base() - rhs.base()) {
332 return lhs.base() - rhs.base();
341template <
typename Iterator>
352template <
typename Iterator>
An iterator adaptor that wraps another iterator such that dereferencing the wrapped iterator yields a...
Definition move_iterator.hpp:35
auto operator[](difference_type delta) const -> reference
Access the value at a specified offset from the current iterator.
Definition move_iterator.hpp:237
auto operator+=(difference_type delta) -> move_iterator &
Move the current iterator forwards by a specified amount.
Definition move_iterator.hpp:194
auto operator*() const -> reference
Dereference the iterator.
Definition move_iterator.hpp:125
move_iterator(Iterator iter) noexcept(is_nothrow_copy_constructible_v< Iterator >)
Construct an iterator holding the specified value of the underlying iterator.
Definition move_iterator.hpp:76
move_iterator() noexcept(is_nothrow_default_constructible_v< Iterator >)
Default construct the iterator, holding a default-constructed underlying iterator....
Definition move_iterator.hpp:71
auto operator-(difference_type delta) const -> move_iterator
Obtain a new iterator referencing the value from moving the current iterator backwards by a specified...
Definition move_iterator.hpp:208
auto operator->() const -> pointer
Arrow dereference operator for accessing the referenced value.
Definition move_iterator.hpp:130
~move_iterator()=default
Default destructor.
auto base() const -> iterator_type
Retrieve the underlying iterator.
Definition move_iterator.hpp:119
auto operator=(move_iterator< OtherIterator > const &source) -> move_iterator &
Conversion assignment from another move iterator with a different type of underlying iterator....
Definition move_iterator.hpp:112
move_iterator(move_iterator const &)=default
Default copy constructor.
auto operator-=(difference_type delta) -> move_iterator &
Move the current iterator backwards by a specified amount.
Definition move_iterator.hpp:222
auto operator++(int) -> move_iterator
Postincrement operator. Increments the stored iterator.
Definition move_iterator.hpp:141
auto operator++() -> move_iterator &
Preincrement operator. Increments the stored iterator.
Definition move_iterator.hpp:134
auto operator--(int) -> move_iterator
Postdecrement operator. Decrements the stored iterator.
Definition move_iterator.hpp:163
auto operator--() -> move_iterator &
Predecrement operator. Decrements the stored iterator.
Definition move_iterator.hpp:151
move_iterator(move_iterator< OtherIterator > const &source)
Conversion constructor from another move iterator with a different type of underlying iterator....
Definition move_iterator.hpp:100
auto operator+(difference_type delta) const -> move_iterator
Obtain a new iterator referencing the value from moving the current iterator forwards by a specified ...
Definition move_iterator.hpp:180
auto operator=(move_iterator &&) -> move_iterator &=default
Default move assignment operator.
auto operator=(move_iterator const &) -> move_iterator &=default
Default copy assignment operator.
move_iterator(move_iterator &&)=default
Default move constructor.
auto operator<=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is less than or equal to another.
Definition move_iterator.hpp:294
auto operator>=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is greater than or equal to another.
Definition move_iterator.hpp:316
auto operator!=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if two iterators are not equal.
Definition move_iterator.hpp:271
auto operator+(typename move_iterator< Iterator >::difference_type delta, move_iterator< Iterator > const &iter) -> move_iterator< Iterator >
Obtain a new iterator referencing the value from moving the specified iterator forwards by a specifie...
Definition move_iterator.hpp:342
auto operator<(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is less than another.
Definition move_iterator.hpp:283
auto make_move_iterator(Iterator iter) -> std::move_iterator< Iterator >
Create a move_iterator with the specified underlying iterator.
Definition move_iterator.hpp:353
auto operator==(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if two iterators are equal.
Definition move_iterator.hpp:258
auto operator-(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) ->
Obtain the distance between two iterators.
Definition move_iterator.hpp:330
auto operator>(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is greater than another.
Definition move_iterator.hpp:305
constexpr auto operator()(::arene::base::result< void, E > const &value) const noexcept(noexcept(hash< E >{}(std::declval< E const & >()))) -> std::size_t
Calculate the hash of a result.
Definition result.hpp:1827