【发布时间】:2020-03-01 06:08:04
【问题描述】:
我希望能够将需要从中分配的内存池传递给 STL 容器(vector、unordered_map 等)。我找到了this question,但它并没有解决我面临的具体问题。 我已经有一个可以在容器声明中指定的工作自定义分配器,但无法从应用程序中找到一种方法来传递分配器在内部使用的地址(通过放置新运算符)。基本上我想去
发件人:
std::vector<int, myCustomAllocator<int>> myVector;
到:
void* pool = getMemoryPoolAddress();
std::vector<int, myCustomAllocator<int>/*Specify memory pool somehow*/> myVector;
如何将pool 传递给我的分配器?
【问题讨论】:
标签: c++11 memory-management stl dynamic-memory-allocation