码迷,mamicode.com
首页 > 其他好文 > 详细

string::get_allocator

时间:2019-12-31 18:52:14      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:vector   names   cto   include   分配器   contains   The   分配   dealloc   

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

string::get_allocator

标签:vector   names   cto   include   分配器   contains   The   分配   dealloc   

原文地址:https://www.cnblogs.com/xpylovely/p/12125761.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!