17namespace xrt::auxiliary::util {
18template <
typename T,
size_t MaxSize>
class HistoryBuffer;
27 template <
typename T,
size_t MaxSize>
37 using typename base::difference_type;
38 using typename base::iterator_category;
39 using value_type =
const T;
40 using pointer =
const T *;
41 using reference =
const T &;
65 explicit operator bool() const noexcept
114 using base::operator-;
126 operator+(std::ptrdiff_t n)
const noexcept;
130 operator-(std::ptrdiff_t n)
const noexcept;
142 end(container_type &
container,
const RingBufferHelper &helper)
151 container_type *container_{
nullptr};
154 template <
typename T,
size_t MaxSize>
155 inline typename HistoryBufConstIterator<T, MaxSize>::reference
158 auto *ptr = container_->get_at_index(base::index());
159 if (ptr ==
nullptr) {
160 throw std::out_of_range(
"Iterator index out of range");
165 template <
typename T,
size_t MaxSize>
166 inline typename HistoryBufConstIterator<T, MaxSize>::pointer
169 return container_->get_at_index(base::index());
172 template <
typename T,
size_t MaxSize>
176 this->increment_n(1);
180 template <
typename T,
size_t MaxSize>
184 this->decrement_n(1);
188 template <
typename T,
size_t MaxSize>
192 static_cast<base &
>(*this) += n;
196 template <
typename T,
size_t MaxSize>
200 static_cast<base &
>(*this) -= n;
204 template <
typename T,
size_t MaxSize>
213 template <
typename T,
size_t MaxSize>
225template <
typename T,
size_t MaxSize>
229 static_assert(std::is_same<typename std::iterator_traits<const_iterator>::iterator_category,
230 std::random_access_iterator_tag>::value,
231 "Iterator should be random access");
232 return const_iterator::begin(*
this, helper_);
235template <
typename T,
size_t MaxSize>
239 return const_iterator::end(*
this, helper_);
242template <
typename T,
size_t MaxSize>
249template <
typename T,
size_t MaxSize>
Stores some number of values in a ring buffer, overwriting the earliest-pushed-remaining element if o...
Definition u_template_historybuf.hpp:38
const_iterator end() const noexcept
Get a "past the end" (past the newest) const iterator.
Definition u_template_historybuf_const_iterator.inl:251
const_iterator cbegin() const noexcept
Get a const iterator for the oldest element.
Definition u_template_historybuf_const_iterator.inl:227
const_iterator cend() const noexcept
Get a "past the end" (past the newest) const iterator.
Definition u_template_historybuf_const_iterator.inl:237
const_iterator begin() const noexcept
Get a const iterator for the oldest element.
Definition u_template_historybuf_const_iterator.inl:244
Template for base class used by "random-access" iterators and const_iterators, providing all the func...
Definition u_iterator_base.hpp:37
void increment_n(std::size_t n)
Increment an arbitrary amount.
Definition u_iterator_base.hpp:310
static RandomAccessIteratorBase end(const RingBufferHelper &container)
Factory function: construct the "past the end" iterator that can be decremented safely.
Definition u_iterator_base.hpp:124
void decrement_n(std::size_t n)
Decrement an arbitrary amount.
Definition u_iterator_base.hpp:320
bool valid() const noexcept
Is this iterator valid?
Definition u_iterator_base.hpp:279
static RandomAccessIteratorBase begin(const RingBufferHelper &container)
Factory function: construct the "begin" iterator.
Definition u_iterator_base.hpp:117
Class template for const_iterator for HistoryBuffer.
Definition u_template_historybuf_const_iterator.inl:29
Self operator-(std::ptrdiff_t n) const noexcept
Decrement a copy of the iterator by an arbitrary amount.
Definition u_template_historybuf_const_iterator.inl:215
Self operator+(std::ptrdiff_t n) const noexcept
Increment a copy of the iterator by an arbitrary amount.
Definition u_template_historybuf_const_iterator.inl:206
Self & operator-=(std::ptrdiff_t n) noexcept
Decrement by an arbitrary amount.
Definition u_template_historybuf_const_iterator.inl:198
HistoryBufConstIterator()=default
Default-construct an (invalid) iterator.
Self & operator++()
Pre-increment: Advance, then return self.
Definition u_template_historybuf_const_iterator.inl:174
container_type * container() const noexcept
Get the inner container: for internal use.
Definition u_template_historybuf_const_iterator.inl:72
pointer operator->() const noexcept
Smart pointer operator: returns nullptr if invalid.
Definition u_template_historybuf_const_iterator.inl:167
Self & operator+=(std::ptrdiff_t n) noexcept
Increment by an arbitrary amount.
Definition u_template_historybuf_const_iterator.inl:190
reference operator*() const
Dereference operator: throws std::out_of_range if invalid.
Definition u_template_historybuf_const_iterator.inl:156
Self & operator--()
Pre-decrement: Subtract, then return self.
Definition u_template_historybuf_const_iterator.inl:182
bool valid() const noexcept
Is this iterator valid?
Definition u_template_historybuf_const_iterator.inl:59
Self operator--(int) &
Post-decrement: return a copy of initial state after decrementing self.
Definition u_template_historybuf_const_iterator.inl:106
Class template for iterator for HistoryBuffer.
Definition u_template_historybuf_iterator.inl:29
All the bookkeeping for adapting a fixed-size array to a ring buffer.
Definition u_template_historybuf_impl_helpers.hpp:46
Definition comp_scratch.c:130