4 ms·
std vector needs to be countiguous, so you cannot use a segmented storage.
by gpderetta 7y ago
std vector needs to be countiguous, so you cannot use a segmented storage.
- krona 7y agoMost applications need more than one vector. Management of this with custom allocators pays dividends fairly quickly.
- gpderetta 7y agoSorry, there is some confusion here. The OP is literally implementing a custom allocator. I'm saying that using std::vector for the backing store of your allocator is wrong because resizing will invalidate your already allocated objects (which is a no-can-do in a general purpose allocator) and the copying is wasteful. A custom fixed size chunk based allocator woud be better.