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_iterator
  • const_pointer β€” typedef const value_type * const_pointer
  • const_reference β€” typedef const value_type & const_reference
  • const_reverse_iterator β€” typedef std::reverse_iterator< const_iterator > const_reverse_iterator
  • difference_type β€” typedef std::ptrdiff_t difference_type
  • iterator β€” typedef value_type * iterator
  • pointer β€” typedef value_type * pointer
  • reference β€” typedef value_type & reference
  • reverse_iterator β€” typedef std::reverse_iterator< iterator > reverse_iterator
  • size_type β€” typedef std::size_t size_type
  • value_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 edition
  • constexpr const_reference back() const noexcept β€” last element, no exceptions, bestie gets what she asks for
  • constexpr reference back() noexcept β€” last element, mutable version
  • constexpr const_iterator begin() const noexcept β€” start of the const parade
  • constexpr iterator begin() noexcept β€” start of the party
  • constexpr const_iterator cbegin() const noexcept β€” const iterator, but committed to the bit
  • constexpr const_iterator cend() const noexcept β€” const end, same commitment
  • constexpr const_reverse_iterator crbegin() const noexcept β€” const reverse start, queen of backwards
  • constexpr const_reverse_iterator crend() const noexcept β€” const reverse end
  • constexpr const_pointer data() const noexcept β€” raw pointer to the const elements 😌
  • constexpr pointer data() noexcept β€” raw pointer to the elements
  • constexpr bool empty() const noexcept β€” is she empty? (spoiler: for _Nm == 0 yes, otherwise no)
  • constexpr const_iterator end() const noexcept β€” end of the const parade
  • constexpr iterator end() noexcept β€” end of the party
  • constexpr void fill(const value_type &__u) β€” copy __u into every single slot, she's nothing if not thorough πŸ’…
  • constexpr const_reference front() const noexcept β€” first element, const
  • constexpr reference front() noexcept β€” first element, mutable
  • constexpr size_type max_size() const noexcept β€” biggest size she could be
  • constexpr const_reference operator[](size_type __n) const noexcept β€” unchecked index, const. no vibe check, no bounds check, you're on your own fr fr
  • constexpr reference operator[](size_type __n) noexcept β€” unchecked index, mutable
  • constexpr const_reverse_iterator rbegin() const noexcept β€” reverse start, const
  • constexpr reverse_iterator rbegin() noexcept β€” reverse start
  • constexpr const_reverse_iterator rend() const noexcept β€” reverse end, const
  • constexpr reverse_iterator rend() noexcept β€” reverse end
  • constexpr size_type size() const noexcept β€” how many elements, periodt
  • constexpr 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[] is noexcept and 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