allocator::const_pointer
常量提供指向对象类型的类型分配由程序管理的。
typedef const value_type *const_pointer;
备注
指针类型来描述可通过表达式 *ptr,指定所有常量对象,ptr 类模板分配程序对象可以赋值。
示例
// allocator_const_ptr.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>
using namespace std;
int main( )
{
vector <int> v1;
vector <int>::iterator v1Iter;
vector <int>:: allocator_type v1Alloc;
int i;
for ( i = 1 ; i <= 7 ; i++ )
{
v1.push_back( i * 2 );
}
cout << "The original vector v1 is:\n ( " ;
for ( v1Iter = v1.begin( ) ; v1Iter != v1.end( ) ; v1Iter++ )
cout << *v1Iter << " ";
cout << ")." << endl;
allocator<int>::const_pointer v1Ptr;
const int k = 10;
v1Ptr = v1Alloc.address( k );
cout << "The integer's address found has a value of: "
<< *v1Ptr << "." << endl;
}
要求
页眉: <内存>
命名空间: std