That Terminal
A terminal emulator designed for video making purposes.
bitval_array< nwords, bits_per_elem > Class Template Reference

Public Types

using elem_t = unsigned long
 Internal type of atoms in this array.
 

Public Member Functions

constexpr void set (std::size_t index, unsigned value)
 
constexpr unsigned get (std::size_t index) const
 

Static Public Member Functions

static constexpr unsigned get_idx (std::size_t index)
 
static constexpr unsigned get_from (elem_t elem, std::size_t index)
 

Public Attributes

elem_t data [n_mapwords] {}
 Storage of data.
 

Static Public Attributes

static constexpr unsigned elems_per_mapword = sizeof(elem_t)*8 / bits_per_elem
 Number of elements in each atom.
 
static constexpr unsigned n_mapwords = (nwords + elems_per_mapword-1) / elems_per_mapword
 Number of atoms needed to store data.
 

Detailed Description

template<unsigned nwords, unsigned bits_per_elem>
class bitval_array< nwords, bits_per_elem >

An array structure that can be initialized at compile-time and read at both compile-time and run-time. The number of elements and the bit-width of each element must be specified at compile-time. All elements have a maximum bit-width, and exactly that number of bits is used to store the data.

Member Function Documentation

◆ get()

template<unsigned nwords, unsigned bits_per_elem>
constexpr unsigned bitval_array< nwords, bits_per_elem >::get ( std::size_t  index) const
inlineconstexpr

Read value at given index.

Parameters
indexIndex to read at.
Returns
The value at given index.

◆ get_from()

template<unsigned nwords, unsigned bits_per_elem>
static constexpr unsigned bitval_array< nwords, bits_per_elem >::get_from ( elem_t  elem,
std::size_t  index 
)
inlinestaticconstexpr

Read value from internal element.

Parameters
elemCopy of the internal element that stores the value.
indexIndex from which to read.
Returns
The value at given index.

◆ get_idx()

template<unsigned nwords, unsigned bits_per_elem>
static constexpr unsigned bitval_array< nwords, bits_per_elem >::get_idx ( std::size_t  index)
inlinestaticconstexpr

Determine the internal array index at which the given index is stored.

Parameters
indexIndex to query.
Returns
The internal array index.

◆ set()

template<unsigned nwords, unsigned bits_per_elem>
constexpr void bitval_array< nwords, bits_per_elem >::set ( std::size_t  index,
unsigned  value 
)
inlineconstexpr

Set value at given index.

Parameters
indexIndex to set at. Counting starts from zero, and must be less than nwords.
valueValue to assign to that index.

The documentation for this class was generated from the following file: