13template<
size_t LookaheadCount,
typename Iterator>
16 constexpr static size_t max_size = LookaheadCount + 1;
18 using iterator = Iterator;
20 using value_type = iterator_type::value_type;
21 using reference = iterator_type::reference;
22 using const_reference = iterator_type::const_reference;
23 using pointer = iterator_type::pointer;
24 using const_pointer = iterator_type::const_pointer;
34 for (; _it != std::default_sentinel and _size != max_size; ++_it, ++_size) {
43 [[nodiscard]]
constexpr size_t size() const noexcept
52 [[nodiscard]]
constexpr bool empty() const noexcept
57 constexpr explicit operator bool() const noexcept
62 [[nodiscard]]
constexpr bool operator==(std::default_sentinel_t
const &)
const noexcept
72 [[nodiscard]] const_reference
operator[](
size_t i)
const noexcept
84 [[nodiscard]] const_reference
at(
size_t i)
const
99 [[nodiscard]] std::optional<value_type>
next(
size_t i = 1) const noexcept
121 return _cache->
data();
132 if (_it !=
std:default_sentinel) {
145template<
size_t LookaheadCount,
typename Iterator>
146auto make_lookahead_iterator(Iterator &&it)
noexcept
148 return lookahead_iterator<LookaheadCount, std::decay_t<Iterator>>{
hi_forward(it)};
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:238
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Lookahead iterator.
Definition lookahead_iterator.hpp:14
const_reference operator[](size_t i) const noexcept
Get a reference to an item at or beyond the iterator.
Definition lookahead_iterator.hpp:72
constexpr size_t size() const noexcept
The number of entries can be looked ahead.
Definition lookahead_iterator.hpp:43
std::optional< value_type > next(size_t i=1) const noexcept
Get a reference to an item at or beyond the iterator.
Definition lookahead_iterator.hpp:99
const_reference operator*() const noexcept
Get a reference to the value at the iterator.
Definition lookahead_iterator.hpp:110
lookahead_iterator & operator++() noexcept
Increment the iterator.
Definition lookahead_iterator.hpp:126
const_pointer operator->() const noexcept
Get a pointer to the value at the iterator.
Definition lookahead_iterator.hpp:118
constexpr bool empty() const noexcept
Check if the iterator is at end.
Definition lookahead_iterator.hpp:52
const_reference at(size_t i) const
Get a reference to an item at or beyond the iterator.
Definition lookahead_iterator.hpp:84