std::get(std::array)
Aus cppreference.com
<metanoindex/>
<tbody> </tbody> template<size_t I, class T, size_t N > T& get( array<T,N>& a ); |
(1) | (seit C++11) |
template<size_t I, class T, size_t N > T&& get( array<T,N>&& a ); |
(2) | (seit C++11) |
template<size_t I, class T, size_t N > const T& get( const array<T,N>& a ); |
(3) | (seit C++11) |
Extrahiert die
Ith element aus dem Array . Original:
Extracts the
Ith element element from the array. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
I muss ein Integer-Wert im Bereich [0, N) sein. Dies wird bei der Kompilierung durchgesetzt zu at() entgegengesetzt oder operator[]() .Original:
I must be an integer value in range [0, N). This is enforced at compile time as opposed to at() or operator[]().The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| a | - | Array, dessen Inhalt zu extrahieren
Original: array whose contents to extract The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rückgabewert
1)
Verweis auf die
Ith Element a .Original:
Reference to the
Ith element of a.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
Rvalue Verweis auf das Element
Ith a, sofern das Element der L-Wert-Referenz-Typ, wobei in diesem Fall L-Wert Verweis zurückgegeben .Original:
Rvalue reference to the
Ith element of a, unless the element is of lvalue reference type, in which case lvalue reference is returned.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3)
Const Verweis auf die
Ith Element a .Original:
Const reference to the
Ith element of a.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ausnahmen
Beispiel
#include <iostream>
#include <array>
int main()
{
std::array<int, 3> arr;
// set values:
std::get<0>(arr) = 1;
std::get<1>(arr) = 2;
std::get<2>(arr) = 3;
// get values:
std::cout << "(" << std::get<0>(arr) << ", " << std::get<1>(arr)
<< ", " << std::get<2>(arr) << ")\n";
}
Output:
(1, 2, 3)
