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;
295 return lhs.value ==
rhs.value;
319 template <
typename T, T First, T Last>
368 , first_value(
other.first_value)
369 , last_value(
other.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;
578 return (
lhs.value ==
rhs.value) &&
579 (
lhs.first_value ==
rhs.first_value) &&
580 (
lhs.last_value ==
rhs.last_value);
Provides a value that cycles between two limits.
Definition cyclic_value.h:53
A templated set implementation that uses a fixed size buffer.
Definition set.h:2554
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
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
static ETL_CONSTEXPR T last()
Gets the last value.
Definition cyclic_value.h:267
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
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:38
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1109
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition array.h:1085
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1097
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:314