allocator::size_type

可以表示长度的任何序列的无符号整型模板类分配程序对象可以赋值。

typedef size_t size_type;

示例

// allocator_size_type.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>

using namespace std;

int main( )
{
   vector <double> v;
   vector <double> ::iterator vIter;
   vector <double> :: allocator_type vAlloc;

   int j;
   for ( j = 1 ; j <= 7 ; j++ )
   {
      v.push_back( 100.0 * j );
   }

   cout << "The original vector v is:\n ( " ;
   for ( vIter = v.begin( ) ; vIter != v.end( ) ; vIter++ )
      cout << *vIter << " ";
   cout << ")." << endl;

   allocator<double>::size_type vsize;
   vsize = vAlloc.max_size( );

   cout << "The number of doubles that can be allocated before\n"
        << " the free memory in the vector v is used up is: "
        << vsize << "." << endl;
}

示例输出

将生成下面关于x86的输出。

The original vector v is:
 ( 100 200 300 400 500 600 700 ).
The number of doubles that can be allocated before
 the free memory in the vector v is used up is: 536870911.

要求

页眉: <内存>

命名空间: std

请参见

参考

allocator 类