Share via


allocator::size_type

An unsigned integral type that can represent the length of any sequence that an object of template class allocator can allocate.

typedef size_t size_type;

Example

// 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;
}

Sample Output

The following output is for 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.

Requirements

Header: <memory>

Namespace: std

See Also

Reference

allocator Class

Other Resources

allocator Members