Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adapting a pool allocator to certain STL containers

22 views
Skip to first unread message

bitrex

unread,
Oct 19, 2017, 9:16:19 PM10/19/17
to
I have a pool allocator up and running which works OK, but the policy
I'm using (based on the following paper:
<https://pdfs.semanticscholar.org/4321/a91d635d023ab25a743c698be219edcdb1a3.pdf>)

is only really good for allocating a single object into one block of
memory with sufficient size for it at a time.

I notice that the std::allocator template method "allocate" has a
parameter where STL containers can request a count of blocks to allocate
simultaneously. For example it looks like std::basic_string, once it
exceeds a certain size string it keeps on the stack, moves the whole
thing over to the heap at once by requesting a contiguous block of
memory from the allocator large enough to store a char array holding the
entire string.

Is there any way to adapt an allocator designed to return fixed-size
chunks the size of the type it's templated on to this sort of STL container?

Mr Flibble

unread,
Oct 20, 2017, 12:12:30 PM10/20/17
to
No. A string-like container wants its elements to be contiguous.

/Flibble

0 new messages