次の方法で共有


tuple_element クラス <array>

配列の要素の型をラップします。

template<int Idx, class Ty, std::size_t N>
class tuple_element<Idx, <array<Ty, N> > {
    typedef Ty type;
    };

テンプレート名

  • Idx
    要素のオフセット。

  • Ty
    要素の型。

  • N
    配列のサイズ。

解説

このテンプレート クラスは、テンプレート クラス tuple_element クラス <tuple> から特化したクラスです。 入れ子になった typedef (type) は、array の Idx 要素の型のシノニムです。

使用例

 

// std_tr1__array__tuple_element.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 first element " 0" 
    std::tuple_element<0, Myarray>::type val = c0.front(); 
    std::cout << " " << val; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
  

必要条件

ヘッダー: の <配列>

名前空間: std

参照

関連項目

<array>

<tuple>

tuple_element クラス <tuple>