Namensräume
Varianten

std::array

Aus cppreference.com
< cpp‎ | container
 
 
 
std::array
Member-Funktionen
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Elementzugriff zerstört
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::at
array::operator[]
array::front
array::back
array::data
Iteratoren
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::begin
array::cbegin
array::end
array::cend
array::rbegin
array::crbegin
array::rend
array::crend
Kapazität
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::empty
array::size
array::max_size
Modifiers
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::fill
array::swap
Non-Member-Funktionen
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get
swap
Helper-Klassen
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size
tuple_element
 
definiert in Header <array>
template<

    class T,
    std::size_t N

>struct array;
(seit C++11)

std::array ist ein Container zur Kapselung einer Sequenz konstanter Länge.

Diese Struktur hat dieselbe Semantik wie ein C-Array mit konstanter Größe. Die Größe und Effizienz von array<T,N> ist ebenso, wie die des äquivalenten C-Arrays T[N]. Die Struktur bietet die Vorteile eines Standard Containers, wie eine Methode die die Größe angibt oder Iteratoren.

Der Spezialfall ist ein Array mit einer Größe von null (N == 0). In diesem Falle gilt array.begin()== array.end(). Der Aufruf von front() oder back() hat undefiniertes Verhalten.

array ist ein Aggregat-Typ (es hat keinen Konstruktor und keine privaten oder geschützten Elemente), was Aggregate-Initialisierung ermöglicht.

Ein array kann ebenso als Tuple von N von Elementen desselben Types genutzt werden.

Inhaltsverzeichnis

[Bearbeiten]Mitglied Typen

Mitglied Typ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
value_typeT[edit]
size_typesize_t[edit]
difference_typeptrdiff_t[edit]
referencevalue_type&[edit]
const_referenceconst value_type&[edit]
pointerT*[edit]
const_pointerconst T*[edit]
iteratorRandomAccessIterator[edit]
const_iterator
Constant random access iterator
Original:
Constant random access iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]
reverse_iteratorstd::reverse_iterator<iterator>[edit]
const_reverse_iteratorstd::reverse_iterator<const_iterator>[edit]

[Bearbeiten]Member-Funktionen

Elementzugriff
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Zugriff auf angegebene Element mit Überprüfung von Grenzen
Original:
access specified element with bounds checking
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf das erste Element
Original:
access the first element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf das letzte Element
(öffentliche Elementfunktion)[edit]
(C++11)
Direkter Zugang zu dem zugrundeliegenden Array
(öffentliche Elementfunktion)[edit]
Iteratoren
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
liefert einen Iterator an den Anfang
Original:
returns an iterator to the beginning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
liefert einen Iterator bis zum Ende
Original:
returns an iterator to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
gibt einen umgekehrten Iterator an den Anfang
Original:
returns a reverse iterator to the beginning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
gibt einen umgekehrten Iterator bis zum Ende
Original:
returns a reverse iterator to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Kapazität
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
prüft, ob der Container leer ist
Original:
checks whether the container is empty
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
liefert die Anzahl der Elemente
Original:
returns the number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
gibt die maximal mögliche Anzahl von Elementen
Original:
returns the maximum possible number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Operations
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Füllen Sie den Behälter mit angegebenen Wert
Original:
fill the container with specified value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
tauscht die Inhalte
Original:
swaps the contents
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]

[Bearbeiten]Non-Member-Funktionen

lexikographischer Vergleich der Werte in array
(Funktions-Template)[edit]
accesses an element of an array
(Funktions-Template)[edit]
spezialisiert die std::swap Algorithmus
Original:
specializes the std::swap algorithm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktions-Template)[edit]

[Bearbeiten]Helper-Klassen

erhält die Größe eines array
Original:
obtains the size of an array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(class Template-Spezialisierung)[edit]
ermittelt die Art der Elemente der array
Original:
obtains the type of the elements of array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(class Template-Spezialisierung)[edit]

[Bearbeiten]Beispiel

#include <string>#include <iterator>#include <iostream>#include <algorithm>#include <array>   int main(){// Erstellen mit Aggregat-Initialisierung std::array<int, 3> a1{{1,2,3}};// doppelte Klammern werden benötigt std::array<int, 3> a2 ={1, 2, 3};// außer nach = std::array<std::string, 2> a3 ={{std::string("a"), "b"}};   // Container Operationen sind möglichstd::sort(a1.begin(), a1.end());std::reverse_copy(a2.begin(), a2.end(), std::ostream_iterator<int>(std::cout, " "));   // Range basierte for-Schleife ist möglichfor(auto& s: a3)std::cout<< s <<' ';}

Output:

3 2 1 a b
close