Boost object_pool array allocation

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)?
1
2
std::vector< Instr*, boost::pool_allocator<Instr*> > bytecode(bytecode_size) ;
for( auto& ptr : bytecode ) p = bytecode_pool.construct();

http://www.boost.org/doc/libs/1_61_0/libs/pool/doc/html/boost_pool/pool/interfaces.html#boost_pool.pool.interfaces.interfaces.pool_allocator
This seems to work, thank you for your help.
Topic archived. No new replies allowed.