Loading...
Searching...
No Matches
cyclic_value
Embedded Template Library. » Utilities

## Classes

class | etl::cyclic_value< T, First, Last, false >
class | etl::cyclic_value< T, First, Last, true >

## Detailed Description

Provides a value that cycles between two limits.

## Class Documentation

## etl::cyclic_value< T, First, Last, false >

class etl::cyclic_value< T, First, Last, false >

template<typename T, T First, T Last>
class etl::cyclic_value< T, First, Last, false >

Provides a value that cycles between two compile time limits. Supports incrementing and decrementing.

Template Parameters

  T | The type of the variable.
  First | The first value of the range.
  Last | The last value of the range.

### Public Member Functions

ETL_CONSTEXPR | cyclic_value ()
ETL_CONSTEXPR14 | cyclic_value (T initial)
ETL_CONSTEXPR | cyclic_value (const cyclic_value< T, First, Last > &other)
| Copy constructor.
ETL_CONSTEXPR14 cyclic_value & | operator= (const cyclic_value< T, First, Last > &other)
| Assignment operator.
ETL_CONSTEXPR14 void | set (T value_)
ETL_CONSTEXPR14 void | to_first ()
| Resets the value to the first in the range.
ETL_CONSTEXPR14 void | to_last ()
| Resets the value to the last in the range.
ETL_CONSTEXPR14 void | advance (int n)
ETL_CONSTEXPR14 | operator T ()
ETL_CONSTEXPR | operator const T () const
ETL_CONSTEXPR14 cyclic_value & | operator++ ()
| ++ operator.
ETL_CONSTEXPR14 cyclic_value | operator++ (int)
| ++ operator.
ETL_CONSTEXPR14 cyclic_value & | operator-- ()
| – operator.
ETL_CONSTEXPR14 cyclic_value | operator-- (int)
| – operator.
ETL_CONSTEXPR14 cyclic_value & | operator= (T t)
| = operator.
template<const T FIRST2, const T LAST2>
ETL_CONSTEXPR14 cyclic_value & | operator= (const cyclic_value< T, FIRST2, LAST2 > &other)
| = operator.
ETL_CONSTEXPR T | get () const
| Gets the value.
void | swap (cyclic_value< T, First, Last > &other)
| Swaps the values.

### Static Public Member Functions

static ETL_CONSTEXPR T | first ()
| Gets the first value.
static ETL_CONSTEXPR T | last ()
| Gets the last value.

### Friends

void | swap (cyclic_value< T, First, Last > &lhs, cyclic_value< T, First, Last > &rhs)
| Swaps the values.
ETL_CONSTEXPR bool | operator== (const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
| Operator ==.
ETL_CONSTEXPR bool | operator!= (const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
| Operator !=.

#### Constructor & Destructor Documentation

## cyclic_value() [1/2]

template<typename T, T First, T Last>

ETL_CONSTEXPR etl::cyclic_value< T, First, Last, false >::cyclic_value | ( |  | ) |

inline

Default constructor. The initial value is set to the first value.

## cyclic_value() [2/2]

template<typename T, T First, T Last>

ETL_CONSTEXPR14 etl::cyclic_value< T, First, Last, false >::cyclic_value | ( | T | initial | ) |

inline explicit

Constructor. Set to an initial value. Clamped to the range.

#### Member Function Documentation

## advance()

template<typename T, T First, T Last>

ETL_CONSTEXPR14 void etl::cyclic_value< T, First, Last, false >::advance | ( | int | n | ) |

inline

Advances to value by a number of steps.

Parameters

  n | The number of steps to advance.

## operator const T()

template<typename T, T First, T Last>

ETL_CONSTEXPR etl::cyclic_value< T, First, Last, false >::operator const T | ( |  | ) | const

inline

Const conversion operator.

Returns
  The value of the underlying type.

## operator T()

template<typename T, T First, T Last>

ETL_CONSTEXPR14 etl::cyclic_value< T, First, Last, false >::operator T | ( |  | ) |

inline

Conversion operator.

Returns
  The value of the underlying type.

## set()

template<typename T, T First, T Last>

ETL_CONSTEXPR14 void etl::cyclic_value< T, First, Last, false >::set | ( | T | value_ | ) |

inline

Sets the value. Truncates to the First/Last range.

Parameters

  value | The value.

## etl::cyclic_value< T, First, Last, true >

class etl::cyclic_value< T, First, Last, true >

template<typename T, T First, T Last>
class etl::cyclic_value< T, First, Last, true >

Provides a value that cycles between two run time limits. Supports incrementing and decrementing.

Template Parameters

  T | The type of the variable.
  First | The first value of the range.
  Last | The last value of the range.

### Public Member Functions

ETL_CONSTEXPR | cyclic_value ()
ETL_CONSTEXPR | cyclic_value (T first_, T last_)
ETL_CONSTEXPR14 | cyclic_value (T first_, T last_, T initial)
ETL_CONSTEXPR | cyclic_value (const cyclic_value &other)
| Copy constructor.
ETL_CONSTEXPR14 void | set (T first_, T last_)
ETL_CONSTEXPR14 void | set (T value_)
ETL_CONSTEXPR14 void | to_first ()
| Resets the value to the first in the range.
ETL_CONSTEXPR14 void | to_last ()
| Resets the value to the last in the range.
ETL_CONSTEXPR14 void | advance (int n)
ETL_CONSTEXPR14 | operator T ()
ETL_CONSTEXPR | operator const T () const
ETL_CONSTEXPR14 cyclic_value & | operator++ ()
| ++ operator.
ETL_CONSTEXPR14 cyclic_value | operator++ (int)
| ++ operator.
ETL_CONSTEXPR14 cyclic_value & | operator-- ()
| – operator.
ETL_CONSTEXPR14 cyclic_value | operator-- (int)
| – operator.
ETL_CONSTEXPR14 cyclic_value & | operator= (T t)
| = operator.
ETL_CONSTEXPR14 cyclic_value & | operator= (const cyclic_value &other)
| = operator.
ETL_CONSTEXPR T | get () const
| Gets the value.
ETL_CONSTEXPR T | first () const
| Gets the first value.
ETL_CONSTEXPR T | last () const
| Gets the last value.
void | swap (cyclic_value< T, First, Last > &other)
| Swaps the values.

### Friends

void | swap (cyclic_value< T, First, Last > &lhs, cyclic_value< T, First, Last > &rhs)
| Swaps the values.
ETL_CONSTEXPR bool | operator== (const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
| Operator ==.
ETL_CONSTEXPR bool | operator!= (const cyclic_value< T, First, Last > &lhs, const cyclic_value< T, First, Last > &rhs)
| Operator !=.

#### Constructor & Destructor Documentation

## cyclic_value() [1/3]

template<typename T, T First, T Last>

ETL_CONSTEXPR etl::cyclic_value< T, First, Last, true >::cyclic_value | ( |  | ) |

inline

Constructor. Sets 'first' and 'last' to the template parameter values. The initial value is set to the first value.

## cyclic_value() [2/3]

template<typename T, T First, T Last>

ETL_CONSTEXPR etl::cyclic_value< T, First, Last, true >::cyclic_value | ( | T | first_,
|  | T | last_ )

inline

Constructor. Sets the value to the first of the range.

Parameters

  first | The first value in the range.
  last | The last value in the range.

## cyclic_value() [3/3]

template<typename T, T First, T Last>

ETL_CONSTEXPR14 etl::cyclic_value< T, First, Last, true >::cyclic_value | ( | T | first_,
|  | T | last_,
|  | T | initial )

inline

Constructor. Set to an initial value. Clamped to the range.

Parameters

  first | The first value in the range.
  last | The last value in the range.

#### Member Function Documentation

## advance()

template<typename T, T First, T Last>

ETL_CONSTEXPR14 void etl::cyclic_value< T, First, Last, true >::advance | ( | int | n | ) |

inline

Advances to value by a number of steps.

Parameters

  n | The number of steps to advance.

## operator const T()

template<typename T, T First, T Last>

ETL_CONSTEXPR etl::cyclic_value< T, First, Last, true >::operator const T | ( |  | ) | const

inline

Const conversion operator.

Returns
  The value of the underlying type.

## operator T()

template<typename T, T First, T Last>

ETL_CONSTEXPR14 etl::cyclic_value< T, First, Last, true >::operator T | ( |  | ) |

inline

Conversion operator.

Returns
  The value of the underlying type.

## set() [1/2]

template<typename T, T First, T Last>

ETL_CONSTEXPR14 void etl::cyclic_value< T, First, Last, true >::set | ( | T | first_,
|  | T | last_ )

inline

Sets the range. Sets the value to the first of the range.

Parameters

  first | The first value in the range.
  last | The last value in the range.

## set() [2/2]

template<typename T, T First, T Last>

ETL_CONSTEXPR14 void etl::cyclic_value< T, First, Last, true >::set | ( | T | value_ | ) |

inline

Sets the value.

Parameters

  value | The value.