tuple_size クラス <array>

更新 : 2007 年 11 月

配列のサイズをラップします。

template<class Ty, std::size_t N>
class tuple_size<array<Ty, N> > {
    static const unsigned value = N;
    };

テンプレート名

  • Ty
    要素の型。

  • N
    配列のサイズ。

解説

これは、テンプレート クラス tuple_size クラス <tuple> から特化したテンプレートです。配列のサイズ N を値として持つ整数定数式のメンバ value を持ちます。

使用例

 

// std_tr1__array__tuple_size.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 size " 4" 
    std::cout << " " << std::tr1::tuple_size<Myarray>::value; 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 4

必要条件

ヘッダー : <array>

名前空間 : std::tr1

参照

参照

<array>

<tuple>

tuple_size クラス <tuple>