9#include <initializer_list>
32template <
typename T, tenno::size N>
class array
72 constexpr array(std::initializer_list<T> list)
135 if (index >= this->_size)
139 return this->_data[index];
156 return this->_data[0];
171 constexpr T
back() const noexcept
173 return this->_data[this->_size - 1];
197 constexpr const T *
data() const noexcept
217 constexpr bool empty() const noexcept
219 return this->_size == 0;
249 void fill(
const T &value)
noexcept
252 [&value](T &elem) { elem = value; });
271 auto temp = this->_data[i];
272 this->_data[i] = other._data[i];
273 other._data[i] = temp;
291 return this->_data[index];
299 return this->_data[index];
304 tenno::copy(other.begin(), other.end(), this->_data);
342 return index == other.index;
347 return !(*
this == other);
383 return iterator(*
this, this->_size);
416 return _const_iterator;
421 return index == other.index;
426 return !(*
this == other);
495 return _reverse_iterator;
500 return index == other.index;
505 return !(*
this == other);
574 return _const_reverse_iterator;
580 return index == other.index;
586 return !(*
this == other);
constexpr const_reverse_iterator crend() const noexcept
Get an const_reverse_iterator to the end of the array.
constexpr array()
Construct a new array object.
iterator begin() noexcept
Get an iterator to the beginning of the array.
constexpr tenno::size max_size() const noexcept
Get the maximum size of the array.
reverse_iterator rend() noexcept
Get an reverse_iterator to the end of the array.
constexpr const T & operator[](const tenno::size index) const noexcept
Access an element of the array constexpr.
constexpr T & operator[](const tenno::size index) noexcept
Access an element of the array.
constexpr tenno::size size() const noexcept
Get the size of the array.
constexpr const_reverse_iterator crbegin() const noexcept
Get an const_reverse_iterator to the beginning of the array.
iterator end() noexcept
Get an iterator to the end of the array.
reverse_iterator rbegin() noexcept
Get an reverse_iterator to the beginning of the array.
void fill(const T &value) noexcept
Fill the array with a value.
constexpr const_iterator cbegin() const noexcept
Get an const_iterator to the beginning of the array.
constexpr const T * data() const noexcept
Access the underlying data of the array.
static constexpr tenno::array< T, N > init() noexcept
Initialize all elements of the array to the default value of T.
constexpr array(std::initializer_list< T > list)
Construct a new array object with a list of elements.
constexpr const_iterator cend() const noexcept
Get an const_iterator to the end of the array.
constexpr array(const array &other)
static constexpr T generate_default()
constexpr array & operator=(const array &other) noexcept
T value_type
The type of the elements in the array.
T * data() noexcept
Access an element of the array.
constexpr T front() const noexcept
Access an element of the array.
constexpr bool empty() const noexcept
Check if the array is empty.
constexpr tenno::expected< T, tenno::error > at(const tenno::size index) const noexcept
Access an element of the array.
void swap(array &other) noexcept
Swap the contents of the array with another array.
constexpr T back() const noexcept
Access an element of the array.
constexpr UnaryFunc for_each(InputIt first, InputIt last, UnaryFunc f)
Applies the given function f to the result of dereferencing every element in the range [first,...
constexpr OutputIt copy(InputIt first, InputIt last, OutputIt d_first)
Copies the elements in the range [first, last) to the range beginning at d_first.
A const iterator to iterate over the array.
constexpr const_iterator(const tenno::array< T, N > &array_in, const tenno::size end) noexcept
std::forward_iterator_tag iterator_category
constexpr const_iterator operator++(int) noexcept
constexpr bool operator==(const const_iterator &other) const noexcept
constexpr bool operator!=(const const_iterator &other) const noexcept
std::ptrdiff_t difference_type
constexpr T operator*() const noexcept
const tenno::array< T, N > & array
constexpr const_iterator & operator++() noexcept
A const iterator to iterate over the array.
constexpr bool operator==(const const_reverse_iterator &other) const noexcept
constexpr const_reverse_iterator & operator++() noexcept
const tenno::array< T, N > & array
std::forward_iterator_tag iterator_category
constexpr const_reverse_iterator(const tenno::array< T, N > &array_in, const tenno::size end) noexcept
constexpr T operator*() const noexcept
constexpr bool operator!=(const const_reverse_iterator &other) const noexcept
constexpr const_reverse_iterator operator++(int) noexcept
std::ptrdiff_t difference_type
An iterator to iterate over the array.
reference operator*() const noexcept
std::forward_iterator_tag iterator_category
iterator & operator++() noexcept
tenno::array< T, N > & array
bool operator==(const iterator &other) const noexcept
std::ptrdiff_t difference_type
iterator(tenno::array< T, N > &array_in, tenno::size end) noexcept
iterator operator++(int) noexcept
bool operator!=(const iterator &other) const noexcept
A reverse iterator over the array.
std::forward_iterator_tag iterator_category
reverse_iterator & operator++() noexcept
bool operator==(const reverse_iterator &other) const noexcept
std::ptrdiff_t difference_type
reverse_iterator operator++(int) noexcept
reverse_iterator(tenno::array< T, N > &array_in, tenno::size end) noexcept
tenno::array< T, N > & array
bool operator!=(const reverse_iterator &other) const noexcept
reference operator*() const noexcept