31#ifndef ETL_CYCLIC_VALUE_INCLUDED
32#define ETL_CYCLIC_VALUE_INCLUDED
48 template <
typename T, T First = 0, T Last = 0,
bool EtlRuntimeSpecialisation = ((First == 0) && (Last == 0))>
59 template <
typename T, T First, T Last>
106 ETL_CONSTEXPR14
void set(T value_)
135 for (
int i = 0; i < n; ++i)
142 for (
int i = 0; i < -n; ++i)
153 ETL_CONSTEXPR14
operator T()
162 ETL_CONSTEXPR
operator const T()
const
172 if (value >= Last) ETL_UNLIKELY
201 if (value <= First) ETL_UNLIKELY
237 template <const T FIRST2, const T LAST2>
247 ETL_CONSTEXPR T
get()
const
273 using ETL_OR_STD::swap;
275 swap(value, other.value);
291 return lhs.value == rhs.value;
299 return !(lhs == rhs);
315 template <
typename T, T First, T Last>
340 , first_value(first_)
353 : first_value(first_)
364 , first_value(other.first_value)
365 , last_value(other.last_value)
375 ETL_CONSTEXPR14
void set(T first_, T last_)
377 first_value = first_;
386 ETL_CONSTEXPR14
void set(T value_)
388 value =
etl::clamp(value_, first_value, last_value);
415 for (
int i = 0; i < n; ++i)
422 for (
int i = 0; i < -n; ++i)
433 ETL_CONSTEXPR14
operator T()
442 ETL_CONSTEXPR
operator const T()
const
452 if (value >= last_value)
481 if (value <= first_value)
520 first_value = other.first_value;
521 last_value = other.last_value;
528 ETL_CONSTEXPR T
get()
const
554 using ETL_OR_STD::swap;
556 swap(first_value, other.first_value);
557 swap(last_value, other.last_value);
558 swap(value, other.value);
574 return (lhs.value == rhs.value) && (lhs.first_value == rhs.first_value) && (lhs.last_value == rhs.last_value);
582 return !(lhs == rhs);
Provides a value that cycles between two limits.
Definition cyclic_value.h:49
ETL_CONSTEXPR T clamp(const T &value, const T &low, const T &high, TCompare compare)
Definition algorithm.h:2353
ETL_CONSTEXPR14 void advance(int n)
Definition cyclic_value.h:411
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:271
friend void swap(cyclic_value< T, First, Last > &lhs, cyclic_value< T, First, Last > &rhs)
Swaps the values.
Definition cyclic_value.h:281
ETL_CONSTEXPR14 cyclic_value & operator=(const cyclic_value< T, First, Last > &other)
Assignment operator.
Definition cyclic_value.h:94
ETL_CONSTEXPR14 void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:114
ETL_CONSTEXPR14 void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:122
ETL_CONSTEXPR14 void set(T first_, T last_)
Definition cyclic_value.h:375
friend ETL_CONSTEXPR bool operator!=(const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
Operator !=.
Definition cyclic_value.h:297
ETL_CONSTEXPR14 cyclic_value & operator=(const cyclic_value< T, FIRST2, LAST2 > &other)
= operator.
Definition cyclic_value.h:238
ETL_CONSTEXPR14 void set(T value_)
Definition cyclic_value.h:106
ETL_CONSTEXPR14 cyclic_value operator++(int)
++ operator.
Definition cyclic_value.h:467
ETL_CONSTEXPR T get() const
Gets the value.
Definition cyclic_value.h:247
ETL_CONSTEXPR T last() const
Gets the last value.
Definition cyclic_value.h:544
ETL_CONSTEXPR T get() const
Gets the value.
Definition cyclic_value.h:528
ETL_CONSTEXPR14 cyclic_value(T initial)
Definition cyclic_value.h:78
friend ETL_CONSTEXPR bool operator==(const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
Operator ==.
Definition cyclic_value.h:289
ETL_CONSTEXPR14 cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:450
ETL_CONSTEXPR cyclic_value()
Definition cyclic_value.h:325
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:552
ETL_CONSTEXPR14 void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:394
ETL_CONSTEXPR14 cyclic_value operator--(int)
– operator.
Definition cyclic_value.h:216
ETL_CONSTEXPR14 cyclic_value & operator=(const cyclic_value &other)
= operator.
Definition cyclic_value.h:517
ETL_CONSTEXPR T first() const
Gets the first value.
Definition cyclic_value.h:536
static ETL_CONSTEXPR T last()
Gets the last value.
Definition cyclic_value.h:263
ETL_CONSTEXPR cyclic_value()
Definition cyclic_value.h:68
ETL_CONSTEXPR14 cyclic_value & operator=(T t)
= operator.
Definition cyclic_value.h:228
ETL_CONSTEXPR14 cyclic_value operator--(int)
– operator.
Definition cyclic_value.h:496
ETL_CONSTEXPR14 cyclic_value & operator=(T t)
= operator.
Definition cyclic_value.h:508
ETL_CONSTEXPR14 cyclic_value operator++(int)
++ operator.
Definition cyclic_value.h:187
ETL_CONSTEXPR14 cyclic_value & operator--()
– operator.
Definition cyclic_value.h:199
ETL_CONSTEXPR14 cyclic_value & operator--()
– operator.
Definition cyclic_value.h:479
ETL_CONSTEXPR cyclic_value(const cyclic_value< T, First, Last > &other)
Copy constructor.
Definition cyclic_value.h:86
static ETL_CONSTEXPR T first()
Gets the first value.
Definition cyclic_value.h:255
ETL_CONSTEXPR14 void set(T value_)
Definition cyclic_value.h:386
ETL_CONSTEXPR14 void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:402
ETL_CONSTEXPR14 cyclic_value(T first_, T last_, T initial)
Definition cyclic_value.h:352
ETL_CONSTEXPR14 cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:170
ETL_CONSTEXPR cyclic_value(T first_, T last_)
Definition cyclic_value.h:338
ETL_CONSTEXPR cyclic_value(const cyclic_value &other)
Copy constructor.
Definition cyclic_value.h:362
ETL_CONSTEXPR14 void advance(int n)
Definition cyclic_value.h:131
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