Skip to content

boost fast_pool_allocator replacement #154

Answered by foonathan
rwis42 asked this question in Q&A
Discussion options

You must be logged in to vote

First, which of the allocators would be best for a unordered_map?

To be frank, none - unordered_map wants both array and individual node allocation, which isn't ideal. The closest would be memory_pool<array_pool>, but you should benchmark whether it's actually faster.

The boost allocators are backed by pools that are owned by singletons, so they get automatically created. Is there something equivalent with this library?

No, you had to roll it your own.

Something like:

auto& pool()
{
    static memory_pool<array_pool> pool;
    return pool;
}

(Keep in mind that this can cause issues with destruction order though.)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rwis42
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants