其他分享
首页 > 其他分享> > string::get_allocator

string::get_allocator

作者:互联网

allocator_type get_allocator() const noexcept;

返回和对象相关的分配器的一个拷贝

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<char> myv;
char *p;
unsigned int i;
p = myv.get_allocator().allocate(5);
for(i = 0; i< 5; i++)
myv.get_allocator().construct(&p[i], 63 + i);
cout << "the allocated array contains:";
for(i = 0; i< 5; i++)
cout << p[i] << ' ';
cout << endl;
for(i = 0; i < 5; i++)
myv.get_allocator().destroy(&p[i]);
myv.get_allocator().deallocate(p, 5);
}

标签:cout,get,++,myv,include,allocator,string
来源: https://www.cnblogs.com/xpylovely/p/12125761.html