[Home]vector

Synopsis

template<
      typename T1 = implementation-defined
    , typename T2 = implementation-defined
    , ...
    , typename Tn = implementation-defined
    >
struct vector
{
};

Description

vectorは型のランダムアクセスシーケンスである. 定数時間での末尾要素の挿入と削除(push_backによる), そして線形時間の先頭及び中間要素の挿入と削除 ( insert/erase アルゴリズム)をサポートする拡張シーケンスでもある. typeofの拡張をサポートするコンパイラでは,vectorは最も単純で, 多くの場合,最も効率的なシーケンスである[1].

Example

typedef vector<float,double,long double> floats;
typedef push_back<floating_types,my_float>::type ext_floats;
typedef at_c<3,ext_floats>::type my;
BOOST_STATIC_ASSERT((boost::is_same<my,my_float>::value));

Definition

#include "boost/mpl/vector.hpp"
#include "boost/mpl/vector/vector0.hpp"
#include "boost/mpl/vector/vector10.hpp"
...
#include "boost/mpl/vector/vector50.hpp"

注記

[1] typeof演算子によって,最小のコードの量でシーケンスの要素への 定数時間ランダムアクセスを実装するためのオーバーロード解決が可能にある (通常のブルートフォースのアプローチとは異なり, ライブラリはtypeof演算子が使えない時,別の手段を必要とする.)

struct null_node
{
    static aux::type_wrapper<void_> item(...);
};

template< long N, typename T, typename Base > struct node : Base { using Base::item; static aux::type_wrapper<T> item(integral_c<long,N>); };

template< typename V, long N > struct at { typedef __typeof__(V::item(integral_c<long,N>())) wrapped_type_; typedef typename wrapped_type_::type type; };

typedef node<1,char,node<0,int,null_node> > v; typedef at<v,0>::type t; // constant-time random access! BOOST_STATIC_ASSERT((is_same<t,int>::value));


See also

Random Access Sequence, vector_c, list, list_c, range_c


Table of Contents
Last edited July 22, 2002 4:28 pm