tuple_element クラス <array>

更新 : 2007 年 11 月

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

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::tr1::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::tr1::tuple_element<0, Myarray>::type val = c0.front(); 
    std::cout << " " << val; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 0

必要条件

ヘッダー : <array>

名前空間 : std::tr1

参照

参照

<array>

<tuple>

tuple_element クラス <tuple>