29 #ifndef __ETL_CYCLIC_VALUE__
30 #define __ETL_CYCLIC_VALUE__
40 #include "static_assert.h"
53 template <
typename T, const T FIRST = T(), const T LAST = T()>
58 template <
typename U, const U OTHER_FIRST, const U OTHER_LAST>
friend class cyclic_value;
91 void set(
const T& first_,
const T& last_)
122 for (
int i = 0; i < n; ++i)
129 for (
int i = 0; i < -n; ++i)
149 operator const T()
const
159 if (value == last_value)
188 if (value == first_value)
224 template <const T OTHER_FIRST, const T OTHER_LAST>
228 first_value = other.first_value;
229 last_value = other.last_value;
252 template <const T OTHER_FIRST, const T OTHER_LAST>
255 std::swap(first_value, other.first_value);
270 template <
typename T, const T LHS_FIRST, const T LHS_LAST, const T RHS_FIRST, const T RHS_LAST>
271 void swap(cyclic_value<T, LHS_FIRST, LHS_LAST>& lhs,
272 cyclic_value<T, RHS_FIRST, RHS_LAST>& rhs)
280 template <
typename T, const T LHS_FIRST, const T LHS_LAST, const T RHS_FIRST, const T RHS_LAST>
281 bool operator == (
const cyclic_value<T, LHS_FIRST, LHS_LAST>& lhs,
282 const cyclic_value<T, RHS_FIRST, RHS_LAST>& rhs)
284 return static_cast<T
>(lhs) == static_cast<T>(rhs);
290 template <
typename T, const T LHS_FIRST, const T LHS_LAST, const T RHS_FIRST, const T RHS_LAST>
291 bool operator != (
const cyclic_value<T, LHS_FIRST, RHS_LAST>& lhs,
292 const cyclic_value<T, RHS_FIRST, RHS_LAST>& rhs)
294 return !(lhs == rhs);
void swap(etl::bitset< N > &lhs, etl::bitset< N > &rhs)
swap
Definition: bitset.h:1200
cyclic_value & operator--()
– operator.
Definition: cyclic_value.h:186
Definition: algorithm.h:43
cyclic_value(const T &first_, const T &last_)
Definition: cyclic_value.h:78
cyclic_value & operator=(T t)
= operator.
Definition: cyclic_value.h:215
const T & last() const
Gets the last value.
Definition: cyclic_value.h:244
Definition: cyclic_value.h:54
const T & first() const
Gets the first value.
Definition: cyclic_value.h:236
void set(const T &first_, const T &last_)
Definition: cyclic_value.h:91
cyclic_value & operator++()
++ operator.
Definition: cyclic_value.h:157
void advance(int n)
Definition: cyclic_value.h:118
void to_first()
Resets the value to the first in the range.
Definition: cyclic_value.h:101
void to_last()
Resets the value to the last in the range.
Definition: cyclic_value.h:109
void swap(cyclic_value< T, OTHER_FIRST, OTHER_LAST > &other)
Swaps the values.
Definition: cyclic_value.h:253
cyclic_value()
The initial value is set to the first value.
Definition: cyclic_value.h:65