17namespace xrt::auxiliary::util {
18template <
typename T,
size_t MaxSize>
class HistoryBuffer;
27 template <
typename T,
size_t MaxSize>
36 using typename base::difference_type;
37 using typename base::iterator_category;
40 using reference = T &;
61 explicit operator bool() const noexcept
110 using base::operator-;
122 operator+(std::ptrdiff_t n)
const noexcept;
126 operator-(std::ptrdiff_t n)
const noexcept;
138 end(container_type &
container,
const RingBufferHelper &helper)
146 container_type *container_{
nullptr};
149 template <
typename T,
size_t MaxSize>
150 inline typename HistoryBufIterator<T, MaxSize>::reference
153 auto *ptr = container_->get_at_index(base::index());
154 if (ptr ==
nullptr) {
155 throw std::out_of_range(
"Iterator index out of range");
160 template <
typename T,
size_t MaxSize>
161 inline typename HistoryBufIterator<T, MaxSize>::pointer
164 return container_->get_at_index(base::index());
167 template <
typename T,
size_t MaxSize>
171 this->increment_n(1);
175 template <
typename T,
size_t MaxSize>
179 this->decrement_n(1);
183 template <
typename T,
size_t MaxSize>
187 static_cast<base &
>(*this) += n;
191 template <
typename T,
size_t MaxSize>
195 static_cast<base &
>(*this) -= n;
199 template <
typename T,
size_t MaxSize>
208 template <
typename T,
size_t MaxSize>
218 template <
typename T,
size_t MaxSize>
226template <
typename T,
size_t MaxSize>
230 static_assert(std::is_same<typename std::iterator_traits<iterator>::iterator_category,
231 std::random_access_iterator_tag>::value,
232 "Iterator should be random access");
233 return iterator::begin(*
this, helper_);
236template <
typename T,
size_t MaxSize>
240 return iterator::end(*
this, helper_);
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 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
HistoryBufConstIterator()=default
Default-construct an (invalid) iterator.
Class template for iterator for HistoryBuffer.
Definition u_template_historybuf_iterator.inl:29
bool valid() const noexcept
Is this iterator valid?
Definition u_template_historybuf_iterator.inl:55
Self operator-(std::ptrdiff_t n) const noexcept
Decrement a copy of the iterator by an arbitrary amount.
Definition u_template_historybuf_iterator.inl:210
reference operator*() const
Dereference operator: throws std::out_of_range if invalid.
Definition u_template_historybuf_iterator.inl:151
Self operator--(int)
Post-decrement: return a copy of initial state after decrementing self.
Definition u_template_historybuf_iterator.inl:102
Self & operator+=(std::ptrdiff_t n) noexcept
Increment by an arbitrary amount.
Definition u_template_historybuf_iterator.inl:185
container_type * container() const noexcept
Get the associated container: for internal use.
Definition u_template_historybuf_iterator.inl:68
pointer operator->() const noexcept
Smart pointer operator: returns nullptr if invalid.
Definition u_template_historybuf_iterator.inl:162
Self & operator--()
Pre-decrement: Subtract, then return self.
Definition u_template_historybuf_iterator.inl:177
Self & operator-=(std::ptrdiff_t n) noexcept
Decrement by an arbitrary amount.
Definition u_template_historybuf_iterator.inl:193
Self operator+(std::ptrdiff_t n) const noexcept
Increment a copy of the iterator by an arbitrary amount.
Definition u_template_historybuf_iterator.inl:201
HistoryBufIterator()=default
Default-construct an (invalid) iterator.
Self & operator++()
Pre-increment: Advance, then return self.
Definition u_template_historybuf_iterator.inl:169
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