[Home]size

Synopsis

template<
      typename Sequence
    >
struct size
{
    typedef unspecified type;
};

Description

sizeはシーケンスの要素の数を返す. つまり, [begin<Sequence>::type,end<Sequence>::type)の範囲の要素の数である.

Definition

#include "boost/mpl/size.hpp"

Parameters

 Parameter  Requirement  Description  
SequenceSequenceのモデルである

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef size<Sequence>::type s;Integral Constantのモデル typedef distance< begin<Sequence>::type,end<Sequence>::type >::type s;と等価 s::value >= 0

Complexity

sizeアルゴリズムの計算量は,適用される特定のシーケンスの実装に直接依存する. 最悪の場合,sizeは線形時間である. 一般規則として,もしSequenceランダムアクセスシーケンス なら,size<Sequence>::typeは償却定数時間演算である. 逆は必ずしも真ではない - 例えば,順シーケンスのモデルは, 償却定数時間のsize計算量であり得る. より詳細は,具体的なシーケンスのドキュメントを見て欲しい.

Example

typedef list0<> empty_list;
typedef vector_c<int,0,1,2,3,4,5> numbers;
typedef range_c<int,0,100> more_numbers;

BOOST_STATIC_ASSERT(size<list>::type::value == 0); BOOST_STATIC_ASSERT(size<numbers>::type::value == 5); BOOST_STATIC_ASSERT(size<more_numbers>::type::value == 100);

See also

Sequence, empty, begin, end


Table of Contents
Last edited July 17, 2002 3:51 am