다음을 통해 공유


get Function <array>

Returns a reference to arr[Idx].

template<int Idx, class Ty, std::size_t N>
    Ty& get(array<Ty, N>& arr);
template<int Idx, class Ty, std::size_t N>
    const Ty& get(const array<Ty, N>& arr);

Parameters

  • Idx
    The element offset.

  • Ty
    The type of an element.

  • N
    The size of the array.

  • arr
    The array to select from.

Example

 

// std_tr1__array__get.cpp 
// compile with: /EHsc 
#include <array> 
#include <iostream> 
 
typedef std::array<int, 4> Myarray; 
int main() 
    { 
    Myarray c0 = {0, 1, 2, 3}; 
 
// display contents " 0 1 2 3" 
    for (Myarray::const_iterator it = c0.begin(); 
        it != c0.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
// display odd elements " 1 3" 
    std::cout << " " << std::get<1>(c0); 
    std::cout << " " << std::get<3>(c0); 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 1 3

Requirements

Header: <array>

Namespace: std

See Also

Reference

<array>

tuple_element Class <array>