STD::ARRAY(3cxx)
π NAME π
std::array< _Tp, _Nm > β a standard container for storing a fixed size sequence of elements π
okay so real quick, this page lives in the 3cxx manual section, and it's literally the whole glow-up of "array but make it a real container." she's fixed size, she's stack-friendly, she's that girl. β¨
π SYNOPSIS π
#include <array>
π¦ Public Types
const_iteratorβtypedef const value_type * const_iteratorconst_pointerβtypedef const value_type * const_pointerconst_referenceβtypedef const value_type & const_referenceconst_reverse_iteratorβtypedef std::reverse_iterator< const_iterator > const_reverse_iteratordifference_typeβtypedef std::ptrdiff_t difference_typeiteratorβtypedef value_type * iteratorpointerβtypedef value_type * pointerreferenceβtypedef value_type & referencereverse_iteratorβtypedef std::reverse_iterator< iterator > reverse_iteratorsize_typeβtypedef std::size_t size_typevalue_typeβtypedef _Tp value_type
ngl that's a whole lot of typedefs but they're all just aliases doing their little jobs π«Ά
πΈ Public Member Functions
constexpr reference at(size_type __n)β bounds-checked access, and she will throw if you get messy πconstexpr const_reference at(size_type __n) constβ same energy, const editionconstexpr const_reference back() const noexceptβ last element, no exceptions, bestie gets what she asks forconstexpr reference back() noexceptβ last element, mutable versionconstexpr const_iterator begin() const noexceptβ start of the const paradeconstexpr iterator begin() noexceptβ start of the partyconstexpr const_iterator cbegin() const noexceptβ const iterator, but committed to the bitconstexpr const_iterator cend() const noexceptβ const end, same commitmentconstexpr const_reverse_iterator crbegin() const noexceptβ const reverse start, queen of backwardsconstexpr const_reverse_iterator crend() const noexceptβ const reverse endconstexpr const_pointer data() const noexceptβ raw pointer to the const elements πconstexpr pointer data() noexceptβ raw pointer to the elementsconstexpr bool empty() const noexceptβ is she empty? (spoiler: for_Nm == 0yes, otherwise no)constexpr const_iterator end() const noexceptβ end of the const paradeconstexpr iterator end() noexceptβ end of the partyconstexpr void fill(const value_type &__u)β copy__uinto every single slot, she's nothing if not thorough πconstexpr const_reference front() const noexceptβ first element, constconstexpr reference front() noexceptβ first element, mutableconstexpr size_type max_size() const noexceptβ biggest size she could beconstexpr const_reference operator[](size_type __n) const noexceptβ unchecked index, const. no vibe check, no bounds check, you're on your own fr frconstexpr reference operator[](size_type __n) noexceptβ unchecked index, mutableconstexpr const_reverse_iterator rbegin() const noexceptβ reverse start, constconstexpr reverse_iterator rbegin() noexceptβ reverse startconstexpr const_reverse_iterator rend() const noexceptβ reverse end, constconstexpr reverse_iterator rend() noexceptβ reverse endconstexpr size_type size() const noexceptβ how many elements, periodtconstexpr void swap(array &__other) noexcept(__array_traits< _Tp, _Nm >::_Is_nothrow_swappable::value)β swap contents with__other, and the noexcept-ness is conditional on__array_traits< _Tp, _Nm >::_Is_nothrow_swappable::valueπ yes that's the actual signature
lowkey important:operator[]isnoexceptand does not bounds-check.at()is the one that checks. don't mix them up bestie, i'm begging π«Ά
β Public Attributes
_M_elemsβ of type__array_traits< _Tp, _Nm >::_Type, i.e. the actual elements sitting right there in the struct. she's not hiding them behind a heap allocation, she's transparent like that π
π Detailed Description π
template<typename _Tp, std::size_t _Nm>
struct std::array< _Tp, _Nm >
"A standard container for storing a fixed size sequence of elements.
Meets the requirements of a container, a reversible container, and a sequence. π
Sets support random access iterators. π₯
π§ Template Parameters
- _Tp_ β Type of element. Required to be a complete type. (yes, required. she's picky about her guests.)
- _Nm_ β Number of elements.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
and that's the whole page bestie, no notes π so before you close the tab: this one's from libstdc++, the page is std::array< _Tp, _Nm >(3cxx), and the credit line up top is Doxygen doing its auto-generated thing from the source code. mwah πβ¨π¦
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms