31#ifndef ETL_CYCLIC_VALUE_INCLUDED
32#define ETL_CYCLIC_VALUE_INCLUDED
41#include "static_assert.h"
51 template <
typename T, T First = 0, T Last = 0,
bool EtlRuntimeSpecialisation = ((First == 0) && (Last == 0))>
62 template <
typename T, T First, T Last>
138 for (
int i = 0; i < n; ++i)
145 for (
int i = 0; i < -n; ++i)
165 operator const T()
const
175 if (value >= Last) ETL_UNLIKELY
204 if (value <= First) ETL_UNLIKELY
240 template <const T FIRST2, const T LAST2>
276 using ETL_OR_STD::swap;
278 swap(value, other.value);
294 return lhs.value == rhs.value;
302 return !(lhs == rhs);
318 template <
typename T, T First, T Last>
343 , first_value(first_)
356 : first_value(first_)
367 , first_value(other.first_value)
368 , last_value(other.last_value)
378 void set(T first_, T last_)
380 first_value = first_;
391 value =
etl::clamp(value_, first_value, last_value);
418 for (
int i = 0; i < n; ++i)
425 for (
int i = 0; i < -n; ++i)
445 operator const T()
const
455 if (value >= last_value)
484 if (value <= first_value)
523 first_value = other.first_value;
524 last_value = other.last_value;
557 using ETL_OR_STD::swap;
559 swap(first_value, other.first_value);
560 swap(last_value, other.last_value);
561 swap(value, other.value);
577 return (lhs.value == rhs.value) && (lhs.first_value == rhs.first_value) && (lhs.last_value == rhs.last_value);
585 return !(lhs == rhs);
Provides a value that cycles between two limits.
Definition cyclic_value.h:52
ETL_CONSTEXPR T clamp(const T &value, const T &low, const T &high, TCompare compare)
Definition algorithm.h:2316
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:274
cyclic_value operator++(int)
++ operator.
Definition cyclic_value.h:470
cyclic_value(T first_, T last_)
Definition cyclic_value.h:341
void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:397
friend void swap(cyclic_value< T, First, Last > &lhs, cyclic_value< T, First, Last > &rhs)
Swaps the values.
Definition cyclic_value.h:284
cyclic_value & operator=(const cyclic_value< T, First, Last > &other)
Assignment operator.
Definition cyclic_value.h:97
cyclic_value & operator=(T t)
= operator.
Definition cyclic_value.h:511
cyclic_value(const cyclic_value< T, First, Last > &other)
Copy constructor.
Definition cyclic_value.h:89
cyclic_value & operator--()
– operator.
Definition cyclic_value.h:202
friend bool operator==(const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
Operator ==.
Definition cyclic_value.h:292
cyclic_value & operator=(T t)
= operator.
Definition cyclic_value.h:231
T last() const
Gets the last value.
Definition cyclic_value.h:547
void advance(int n)
Definition cyclic_value.h:414
void set(T value_)
Definition cyclic_value.h:109
cyclic_value operator++(int)
++ operator.
Definition cyclic_value.h:190
void advance(int n)
Definition cyclic_value.h:134
void set(T first_, T last_)
Definition cyclic_value.h:378
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:555
cyclic_value(T initial)
Definition cyclic_value.h:81
cyclic_value & operator--()
– operator.
Definition cyclic_value.h:482
cyclic_value & operator=(const cyclic_value< T, FIRST2, LAST2 > &other)
= operator.
Definition cyclic_value.h:241
static ETL_CONSTEXPR T last()
Gets the last value.
Definition cyclic_value.h:266
cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:453
cyclic_value(const cyclic_value &other)
Copy constructor.
Definition cyclic_value.h:365
friend bool operator!=(const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
Operator !=.
Definition cyclic_value.h:300
T get() const
Gets the value.
Definition cyclic_value.h:531
T first() const
Gets the first value.
Definition cyclic_value.h:539
cyclic_value(T first_, T last_, T initial)
Definition cyclic_value.h:355
static ETL_CONSTEXPR T first()
Gets the first value.
Definition cyclic_value.h:258
cyclic_value operator--(int)
– operator.
Definition cyclic_value.h:219
cyclic_value()
Definition cyclic_value.h:328
cyclic_value operator--(int)
– operator.
Definition cyclic_value.h:499
cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:173
void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:125
void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:117
cyclic_value & operator=(const cyclic_value &other)
= operator.
Definition cyclic_value.h:520
void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:405
T get() const
Gets the value.
Definition cyclic_value.h:250
void set(T value_)
Definition cyclic_value.h:389
cyclic_value()
Definition cyclic_value.h:71
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:856