G4.9pool alloc用例
来源:互联网 发布:印度经济数据 编辑:程序博客网 时间:2024/05/21 22:37
#include <iostream>#include <vector>#include <ext\pool_allocator.h>using namespace std;template<typename Alloc>void cookie_test(Alloc alloc, size_t n) {typename Alloc::value_type *p1,*p2,*p3;p1 = alloc.allocate(n);p2 = alloc.allocate(n);p3 = alloc.allocate(n);cout << "p1= " << p1 << '\t' << "p2= " << p2 << '\t' << "p3= " << p3 << endl;alloc.deallocate(p1, sizeof(typename Alloc::value_type));alloc.deallocate(p2, sizeof(typename Alloc::value_type));alloc.deallocate(p3, sizeof(typename Alloc::value_type));}int main() {cout << sizeof(__gnu_cxx::__pool_alloc<int>) << endl;vector<int, __gnu_cxx::__pool_alloc<int> > vecPool;cookie_test(__gnu_cxx::__pool_alloc<double>(), 1);//相距08h(表示不带cookie) cout << endl;cout << sizeof(std::allocator<int>) << endl;vector<int, std::allocator<int> > vec;cookie_test(std::allocator<double>(), 1);//相距10h(表示带cookie)return 0;}
G4.9的allocator只是以::operator new和::operator delete完成allocate()和deallocate(),没有任何特殊设计
欲使用std::allocatoe以外的allocator,就得自行//include <ext/...>
阅读全文
1 0
- G4.9pool alloc用例
- alloc
- alloc
- alloc
- G4界面
- POOL
- pool
- Pool
- 苹果的iMac G4
- g4年技术经验
- HTC-G4刷机过程
- 关于alloc
- heap alloc
- 如何运行在Mac G4的豹
- 佳域g4 佳域用户springpark
- 思科交换机接口标示G4/0/1
- G4项目部署注意事项以及重要配置
- HTC G4刷Recovery图文详细教程 教你如何刷G4的Recovery
- 【SpringMVC】文件上传Expected MultipartHttpServletRequest: is a MultipartResolver错误解决【实测可用】
- Python安装scipy,scikit-image时提示"no lapack/blas resources found"的解决方法
- [Leetcode] 159. Longest Substring with At Most Two Distinct Characters 解题报告
- Ubuntu16.04 vm tools安装方法及遇到的问题详解
- LeetCode:House Robber
- G4.9pool alloc用例
- 回调函数
- 用友U8手工清除工作流资料
- UDOO X86比Raspberry Pi性能强10倍 Windows/Linux/Android通吃
- Java标识符的命名方法
- Template by 2015ljn
- Angular常见面试题
- 【算法题】链表归并排序
- 机器学习十大算法--SVM(支持向量机)