array

namespace opentl {
    template <typename T, opentl::size_t N>
    class array;
}

An aggregate container for a fixed-size array.

Template Parameters

Name Description
T The element type.
N The array size.

Member Types

Type Description
value_type The element type.
size_type The size type.
reference The reference type.
const_reference The const reference type.
pointer The pointer type.
const_pointer The const pointer type.
iterator The iterator type.
const_iterator The const iterator type.
reverse_iterator The reverse iterator type.
const_reverse_iterator The const reverse iterator type.

Member Functions

Name Return Type Description
front() reference Returns a reference to the first element.
front() const const_reference Returns a const reference to the first element
back() reference Returns a reference to the last element.
back() const const_reference Returns a const reference to the last element.
data() pointer Returns a pointer to the underlying data.
data() const const_pointer Returns a pointer to the underlying data.
operator[](size_type) reference Returns a reference to the element at the specified index.
operator[](size_type) const const_reference Returns a reference to the element at the specified index.
begin() iterator Returns an iterator to the beginning.
begin() const const_iterator Returns an iterator to the beginning.
end() iterator Returns an iterator to the end.
end() const const_iterator Returns an iterator to the end.
cbegin() const const_iterator Returns an iterator to the beginning.
cend() const const_iterator Returns an iterator to the end.
rbegin() reverse_iterator Returns a reverse iterator to the beginning.
rbegin() const const_reverse_iterator Returns a reverse iterator to the beginning.
rend() reverse_iterator Returns a reverse iterator to the end.
rend() const const_reverse_iterator Returns a reverse iterator to the end.
crbegin() const const_reverse_iterator Returns a reverse iterator to the beginning.
crend() const const_reverse_iterator Returns a reverse iterator to the end.
empty() const bool Returns if the array is empty.
size() const size_type Returns the size of the array.
fill(const value_type&) void Fills the array with the specified value.

Deduction Guide

Guide Description
array(T, U...) -> array<T, sizeof...(U) + 1> Deduces type and size from constructor arguments

Specialization

Specialization Description
array<T, 0> Behaves as an empty container; all accessors return null pointers or throw if dereferenced.

Example

#include <opentl/array.hpp>

int main() {
    opentl::array<int, 3> arr{1, 2, 3};
    arr[0] = 10;
    for (auto x : arr) { /* ... */ }
    arr.fill(0);
}