首页 > 其他 > 详细

string::get_allocator

时间:2019-12-31 20:22:13      阅读:110      评论:0      收藏:0      [点我收藏+]
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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!