Standard library header <array> (C++11)
From cppreference.net
Este encabezado es parte de la biblioteca de contenedores .
Includes |
||
|
(C++20)
|
Soporte para operador de comparación de tres vías | |
|
(C++11)
|
std::initializer_list plantilla de clase | |
Clases |
||
|
(C++11)
|
arreglo contiguo local de tamaño fijo
(plantilla de clase) |
|
|
(C++11)
|
obtiene el número de elementos de un tipo tipo-tupla
(plantilla de clase) |
|
|
(C++11)
|
obtiene los tipos de elemento de un tipo tipo-tupla
(plantilla de clase) |
|
|
(C++11)
|
obtiene el tamaño de un
array
(especialización de plantilla de clase) |
|
|
(C++11)
|
obtiene el tipo de los elementos de
array
(especialización de plantilla de clase) |
|
Funciones |
||
|
(C++11)
(C++11)
(eliminado en C++20)
(C++11)
(eliminado en C++20)
(C++11)
(eliminado en C++20)
(C++11)
(eliminado en C++20)
(C++11)
(eliminado en C++20)
(C++20)
|
compara lexicográficamente los valores de dos
array
s
(plantilla de función) |
|
|
(C++11)
|
especializa el algoritmo
std::swap
(plantilla de función) |
|
|
(C++20)
|
crea un objeto
std::array
a partir de un array incorporado
(plantilla de función) |
|
|
(C++11)
|
accede a un elemento de un
array
(plantilla de función) |
|
Acceso a rangos |
||
|
(C++11)
(C++14)
|
devuelve un iterador al inicio de un contenedor o array
(plantilla de función) |
|
|
(C++11)
(C++14)
|
devuelve un iterador al final de un contenedor o array
(plantilla de función) |
|
|
(C++14)
|
devuelve un iterador inverso al inicio de un contenedor o array
(plantilla de función) |
|
|
(C++14)
|
devuelve un iterador inverso final para un contenedor o array
(plantilla de función) |
|
|
(C++17)
(C++20)
|
devuelve el tamaño de un contenedor o array
(plantilla de función) |
|
|
(C++17)
|
verifica si el contenedor está vacío
(plantilla de función) |
|
|
(C++17)
|
obtiene el puntero al array subyacente
(plantilla de función) |
|
Sinopsis
// mayormente independiente #include <compare> #include <initializer_list> namespace std { // plantilla de clase array template<class T, size_t N> struct array; // parcialmente independiente template<class T, size_t N> constexpr bool operator==(const array<T, N>& x, const array<T, N>& y); template<class T, size_t N> constexpr /*synth-three-way-result*/<T> operator<=>(const array<T, N>& x, const array<T, N>& y); // algoritmos especializados template<class T, size_t N> constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y))); // funciones de creación de array template<class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); template<class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // interfaz de tupla template<class T> struct tuple_size; template<size_t I, class T> struct tuple_element; template<class T, size_t N> struct tuple_size<array<T, N>>; template<size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>; template<size_t I, class T, size_t N> constexpr T& get(array<T, N>&) noexcept; template<size_t I, class T, size_t N> constexpr T&& get(array<T, N>&&) noexcept; template<size_t I, class T, size_t N> constexpr const T& get(const array<T, N>&) noexcept; template<size_t I, class T, size_t N> constexpr const T&& get(const array<T, N>&&) noexcept; }
Plantilla de clase std::array
namespace std { template<class T, size_t N> struct array { // tipos using value_type = T; using pointer = T*; using const_pointer = const T*; using reference = T&; using const_reference = const T&; using size_type = size_t; using difference_type = ptrdiff_t; using iterator = /* implementation-defined */; using const_iterator = /* implementation-defined */; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; // sin constructores/copias/destructores explícitos para tipo agregado constexpr void fill(const T& u); constexpr void swap(array&) noexcept(is_nothrow_swappable_v<T>); // iteradores constexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr reverse_iterator rbegin() noexcept; constexpr const_reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() noexcept; constexpr const_reverse_iterator rend() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept; constexpr const_reverse_iterator crend() const noexcept; // capacidad constexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // acceso a elementos constexpr reference operator[](size_type n); constexpr const_reference operator[](size_type n) const; constexpr reference at(size_type n); // freestanding-deleted constexpr const_reference at(size_type n) const; // freestanding-deleted constexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; constexpr T* data() noexcept; constexpr const T* data() const noexcept; }; template<class T, class... U> array(T, U...) -> array<T, 1 + sizeof...(U)>; }