31 #ifndef ETL_CYCLIC_VALUE_INCLUDED
32 #define ETL_CYCLIC_VALUE_INCLUDED
41 #include "static_assert.h"
43 #include "static_assert.h"
58 template <
typename T, T FIRST = 0, T LAST = 0,
typename =
void>
90 else if (value_ < FIRST)
122 for (
int i = 0; i < n; ++i)
129 for (
int i = 0; i < -n; ++i)
149 operator const T()
const
224 template <const T FIRST2, const T LAST2>
262 swap(value, other.value);
278 return lhs.value == rhs.value;
286 return !(lhs == rhs);
302 template <
typename T, const T FIRST, const T LAST>
336 : value(other.value),
337 first_value(other.first_value),
338 last_value(other.last_value)
348 void set(T first_, T last_)
350 first_value = first_;
361 if (value_ > last_value)
365 else if (value_ < first_value)
367 value_ = first_value;
397 for (
int i = 0; i < n; ++i)
404 for (
int i = 0; i < -n; ++i)
424 operator const T()
const
434 if (value >= last_value)
463 if (value <= first_value)
502 first_value = other.first_value;
503 last_value = other.last_value;
538 swap(first_value, other.first_value);
539 swap(last_value, other.last_value);
540 swap(value, other.value);
556 return (lhs.value == rhs.value) &&
557 (lhs.first_value == rhs.first_value) &&
558 (lhs.last_value == rhs.last_value);
566 return !(lhs == rhs);
void to_first()
Resets the value to the first in the range.
Definition: cyclic_value.h:101
void set(T value_)
Definition: cyclic_value.h:359
void advance(int n)
Definition: cyclic_value.h:393
void swap(cyclic_value< T, FIRST, LAST > &other)
Swaps the values.
Definition: cyclic_value.h:534
cyclic_value()
Definition: cyclic_value.h:312
friend bool operator==(const cyclic_value< T, FIRST, LAST > &lhs, const cyclic_value< T, FIRST, LAST > &rhs)
Operator ==.
Definition: cyclic_value.h:276
void to_first()
Resets the value to the first in the range.
Definition: cyclic_value.h:376
cyclic_value & operator++()
++ operator.
Definition: cyclic_value.h:157
void to_last()
Resets the value to the last in the range.
Definition: cyclic_value.h:109
cyclic_value(T first_, T last_)
Definition: cyclic_value.h:325
cyclic_value(const cyclic_value &other)
Copy constructor.
Definition: cyclic_value.h:335
cyclic_value(const cyclic_value< T, FIRST, LAST > &other)
Copy constructor.
Definition: cyclic_value.h:75
void swap(cyclic_value< T, FIRST, LAST > &other)
Swaps the values.
Definition: cyclic_value.h:258
T get() const
Gets the value.
Definition: cyclic_value.h:510
T get() const
Gets the value.
Definition: cyclic_value.h:234
void set(T first_, T last_)
Definition: cyclic_value.h:348
cyclic_value & operator=(T t)
= operator.
Definition: cyclic_value.h:215
T first() const
Gets the first value.
Definition: cyclic_value.h:518
T last() const
Gets the last value.
Definition: cyclic_value.h:526
friend void swap(cyclic_value< T, FIRST, LAST > &lhs, cyclic_value< T, FIRST, LAST > &rhs)
Swaps the values.
Definition: cyclic_value.h:268
cyclic_value & operator--()
– operator.
Definition: cyclic_value.h:186
const T first() const
Gets the first value.
Definition: cyclic_value.h:242
cyclic_value()
Definition: cyclic_value.h:67
void advance(int n)
Definition: cyclic_value.h:118
const T last() const
Gets the last value.
Definition: cyclic_value.h:250
void to_last()
Resets the value to the last in the range.
Definition: cyclic_value.h:384
void set(T value_)
Definition: cyclic_value.h:84
friend bool operator!=(const cyclic_value< T, FIRST, LAST > &lhs, const cyclic_value< T, FIRST, LAST > &rhs)
Operator !=.
Definition: cyclic_value.h:284
Definition: cyclic_value.h:60
enable_if
Definition: type_traits_generator.h:1228
Definition: absolute.h:37
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition: array.h:570