Question

Is it possible to allocate items of boost::multi_index on vector and use indexes in this vector(4 bytes) instead of pointers(8 bytes) everywhere (including internal structures of boost::multi_index) to save memory?

Was it helpful?

Solution

It might be possible: Boost.MultiIndex supports special allocators whose associated Allocator::pointer type can be something different than a regular pointer provided it models a random access iterator, as explained here (this is done primarly to support Boost.Interprocess allocators.) With some work you might craft an allocator that uses a vector as its arena and uses a 4-byte object to index it. Doesn't look like an easy task, though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top