I would like to find a way to store several std::vectors
, each of a different but known and reasonably small size, in contiguous memory. I realize I could write my own class, say with a very large array and with pointers to the start of each subsection of the array within the larger array treated like a separate entity, but it seems like there should be a smarter way to do this.
Is there a way to use allocators
, for example, to create contiguous std::vectors
? I'd like not to reinvent the wheel just because I want this memory-locality of otherwise normal std::vectors
I don't know how to even begin coding. I need to create an allocator that takes a pointer to memory, allocates a vector there, and then somehow passes back the address of the end of that vector, so the next std::vector
's allocator could grab that and do it again. How can an allocator
return a value?