31#ifndef ETL_CYCLIC_VALUE_INCLUDED
32#define ETL_CYCLIC_VALUE_INCLUDED
39#include "static_assert.h"
41#include "static_assert.h"
52 template <
typename T, T First = 0, T Last = 0,
bool EtlRuntimeSpecialisation = ((First == 0) && (Last == 0))>
63 template <
typename T, T First, T Last>
139 for (
int i = 0; i < n; ++i)
146 for (
int i = 0; i < -n; ++i)
166 operator const T()
const
176 if (value >= Last) ETL_UNLIKELY
205 if (value <= First) ETL_UNLIKELY
241 template <const T FIRST2, const T LAST2>
277 using ETL_OR_STD::swap;
279 swap(value, other.value);
295 return lhs.value == rhs.value;
303 return !(lhs == rhs);
319 template <
typename T, T First, T Last>
344 , first_value(first_)
357 : first_value(first_)
368 , first_value(other.first_value)
369 , last_value(other.last_value)
379 void set(T first_, T last_)
381 first_value = first_;
392 value =
etl::clamp(value_, first_value, last_value);
419 for (
int i = 0; i < n; ++i)
426 for (
int i = 0; i < -n; ++i)
446 operator const T()
const
456 if (value >= last_value)
485 if (value <= first_value)
524 first_value = other.first_value;
525 last_value = other.last_value;
558 using ETL_OR_STD::swap;
560 swap(first_value, other.first_value);
561 swap(last_value, other.last_value);
562 swap(value, other.value);
578 return (lhs.value == rhs.value) &&
579 (lhs.first_value == rhs.first_value) &&
580 (lhs.last_value == rhs.last_value);
588 return !(lhs == rhs);
Provides a value that cycles between two limits.
Definition cyclic_value.h:53
ETL_CONSTEXPR T clamp(const T &value, const T &low, const T &high, TCompare compare)
Definition algorithm.h:2268
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:275
cyclic_value(T first_, T last_)
Definition cyclic_value.h:342
void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:398
friend void swap(cyclic_value< T, First, Last > &lhs, cyclic_value< T, First, Last > &rhs)
Swaps the values.
Definition cyclic_value.h:285
cyclic_value(const cyclic_value< T, First, Last > &other)
Copy constructor.
Definition cyclic_value.h:90
cyclic_value & operator--()
– operator.
Definition cyclic_value.h:203
T last() const
Gets the last value.
Definition cyclic_value.h:548
void advance(int n)
Definition cyclic_value.h:415
void set(T value_)
Definition cyclic_value.h:110
void advance(int n)
Definition cyclic_value.h:135
void set(T first_, T last_)
Definition cyclic_value.h:379
void swap(cyclic_value< T, First, Last > &other)
Swaps the values.
Definition cyclic_value.h:556
cyclic_value(T initial)
Definition cyclic_value.h:82
cyclic_value & operator--()
– operator.
Definition cyclic_value.h:483
static ETL_CONSTEXPR T last()
Gets the last value.
Definition cyclic_value.h:267
cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:454
cyclic_value(const cyclic_value &other)
Copy constructor.
Definition cyclic_value.h:366
T get() const
Gets the value.
Definition cyclic_value.h:532
T first() const
Gets the first value.
Definition cyclic_value.h:540
cyclic_value(T first_, T last_, T initial)
Definition cyclic_value.h:356
static ETL_CONSTEXPR T first()
Gets the first value.
Definition cyclic_value.h:259
cyclic_value()
Definition cyclic_value.h:329
cyclic_value & operator++()
++ operator.
Definition cyclic_value.h:174
void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:126
void to_first()
Resets the value to the first in the range.
Definition cyclic_value.h:118
void to_last()
Resets the value to the last in the range.
Definition cyclic_value.h:406
T get() const
Gets the value.
Definition cyclic_value.h:251
void set(T value_)
Definition cyclic_value.h:390
cyclic_value()
Definition cyclic_value.h:72
bitset_ext
Definition absolute.h:39
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:838
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139