std::get(std::array) (3) - Linux Manuals
std::get(std::array): std::get(std::array)
NAME
std::get(std::array) - std::get(std::array)
Synopsis
template< size_t I, class T, size_t N >                   (1) (since C++11)
constexpr T& get( array<T,N>& a ) noexcept;
template< size_t I, class T, size_t N >                   (2) (since C++11)
constexpr T&& get( array<T,N>&& a ) noexcept;
template< size_t I, class T, size_t N >                   (3) (since C++11)
constexpr const T& get( const array<T,N>& a ) noexcept;
template< size_t I, class T, size_t N >                   (4) (since C++17)
constexpr const T&& get( const array<T,N>&& a ) noexcept;
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.
Complexity
Constant.
Notes
The overloads are marked as constexpr since C++14.
Example
// Run this code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Output:
 See also
 
operator[]             (public member function)
 
at                     (public member function)
 
std::get(std::tuple)   (function template)
std::get(std::pair)    accesses an element of a pair
 
(C++11)
std::get(std::variant) reads the value of the variant given the index or the type (if the type is unique), throws on error
 
(C++17)