std :: vector中的自定义分配器 [英] Custom allocator in std::vector

查看:832
本文介绍了std :: vector中的自定义分配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为 std :: vector 内部分配使用自定义分配器?如果是,如何?

Is it possible to use custom allocator for std::vector internal allocations? If yes, how?

推荐答案

你基本上必须实现你的分配器类型符合 Allocator concept

You basically have to implement your allocator type to conform to the Allocator concept.

链接的页面列出所有但是核心功能在 allocate 成员函数中实现。

The linked page lists all requirements of that type, but the core functionality is implemented in the allocate member function.

这篇关于std :: vector中的自定义分配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆