Lately I have been using the boost::object_pool class to create memory pools in a program I am creating. Currently I need to allocate an array of pointers in this memory pool. Currently I have this:
1 2 3 4
boost::object_pool<Instr> bytecode_pool;
Instr** bytecode = new Instr*[bytecode_size];
for(size_t i = 0; i < bytecode_size; ++i)
bytecode[i] = bytecode_pool.construct();
Here the array of pointers is allocated outside of any memory pool. Is it somehow possible to allocate this array of pointers in a memory pool (optionally another memory pool than the one the Instr instances are stored in themselves)?