| (1) | (since C++11) | ||
| (2) | (since C++11) | ||
| (3) | (since C++11) | ||
| (4) | (since C++17) |
Extracts the Ith
element element from the array.
I
must be an integer value in range [0, N)
. This is enforced at compile time as opposed to at()
or operator[]
.
Parameters
a | - | array whose contents to extract |
Return value
A reference to the Ith
element of a
.
Exceptions
noexcept
specification: noexcept
Notes
The overloads are marked as constexpr
since C++14.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #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 | (1, 2, 3) |
See also
access specified element (public member function) | |
access specified element with bounds checking (public member function) | |
tuple accesses specified element (function template) | |
(C++11) | accesses an element of a pair (function template) |
Please login to continue.