Freigeben über


get Function <array>

Gibt einen Verweis auf arr[Idx] zurück.

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);

Parameter

  • Idx
    Der Elementoffset.

  • Ty
    Der Typ eines Elements.

  • N
    Die Größe des Arrays.

  • arr
    Das Array von auszuwählen.

Beispiel

 

// 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); 
    } 
 
  

Anforderungen

Header: <array>

Namespace: std

Siehe auch

Referenz

<array>

tuple_element Class <array>