function template
<array>
std::get (array)
template <size_t I, class T, size_t N> T& get (array<T,N>& arr) noexcept;template <size_t I, class T, size_t N> T&& get (array<T,N>&& arr) noexcept;template <size_t I, class T, size_t N> const T& get (const array<T,N>& arr) noexcept;
Get element (tuple interface)
This overload of tuple's homonym function get is provided so that array objects can be treated as tuples. For that purpose, header <array> also overloads tuple_size and tuple_element types with the appropriate members defined.
Template parameters
- I
- Position of an element in the array, with 0 as the position of the first element.
size_t is an unsigned integral type. - T
- Type of elements contained in the array (generally obtained implicitly from arr).
- N
- Size of the array, in number of elements (generally obtained implicitly from arr).
Function parameters
- arr
- An array container.
Return value
A reference to the element at the specified position in the array.Example
|
|
Output:
first element in myarray: 30 first element in mytuple: 10
Complexity
Constant.Iterator validity
No changes.Data races
Element I of arr is potentially accessed or modified by the caller. Concurrently accessing or modifying other elements of arr is safe.Exception safety
No-throw guarantee: this function never throws exceptions.See also
- array::at
- Access element (public member function)
- array::operator[]
- Access element (public member function)