absl::FixedArray

A run-time fixed-size array that allocates small arrays inline.

Synopsis

Declared in <absl/container/fixed_array.h>

template<
    typename T,
    size_t N = kFixedArrayUseDefault,
    typename A = std::allocator<T>>
class FixedArray;

Description

A FixedArray provides a run-time fixed-size array, allocating a small array inline for efficiency.

Most users should not specify the N template parameter and let FixedArray automatically determine the number of elements to store inline based on sizeof(T). If N is specified, the FixedArray implementation will use inline storage for arrays with a length <= N.

Note that a FixedArray constructed with a size_type argument will default-initialize its values by leaving trivially constructible types uninitialized (e.g. int, int[4], double), and others default-constructed. This matches the behavior of c-style arrays and std::array, but not std::vector.

Type Aliases

NameDescription
allocator_type The allocator type used to allocate and construct elements.
const_iterator A random-access iterator over const elements.
const_pointer A pointer to a const element.
const_reference A reference to a const element.
const_reverse_iterator A reverse iterator over const elements.
difference_type A signed integral type used for iterator differences.
iterator A random-access iterator over the elements.
pointer A pointer to an element.
reference A reference to an element.
reverse_iterator A reverse iterator over the elements.
size_type An unsigned integral type used for sizes and indices.
value_type The type of the elements stored in the fixed array.

Member Functions

NameDescription
FixedArray [constructor]Constructors
~FixedArray [destructor]Destroys the fixed array and its elements.
operator= Assignment operators
at at overloads
back back overloads
begin begin overloads
cbegin Returns a const iterator to the beginning of the fixed array.
cend Returns a const iterator to the end of the fixed array.
crbegin Returns a const reverse iterator from the end of the fixed array.
crend Returns a const reverse iterator from the beginning of the fixed array.
data data overloads
empty Returns whether or not the fixed array is empty.
end end overloads
fill Assigns the given value to all elements in the fixed array.
front front overloads
max_size Returns the largest possible value of std::distance(begin(), end()) for a FixedArray<T>. This is equivalent to the most possible addressable bytes over the number of bytes taken by T.
memsize Returns the memory size of the fixed array in bytes.
operator[] Subscript operators
rbegin rbegin overloads
rend rend overloads
size Returns the length of the fixed array.

Static Data Members

NameDescription
inline_elements The number of elements stored inline before heap allocation is used.

Friends

NameDescription
absl::AbslHashValueCombines the contents of the fixed array into a hash state.
absl::operator>=Returns whether lhs orders lexicographically after or equal to rhs.
absl::operator<=Returns whether lhs orders lexicographically before or equal to rhs.
absl::operator>Returns whether lhs orders lexicographically after rhs.
absl::operator<Returns whether lhs orders lexicographically before rhs.
absl::operator!=Returns whether two fixed arrays are not elementwise equal.
absl::operator==Returns whether two fixed arrays are elementwise equal.