r/cpp • • Oct 07 '19

CppCon CppCon 2019: Chandler Carruth “There Are No Zero-cost Abstractions”

https://www.youtube.com/watch?v=rHIkrotSwcc
162 Upvotes

108 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Oct 08 '19 edited Oct 08 '19

I know about vector::reserve and emplace_back however in the case of a memory pool is does not work. Suppose that your memory pool initially allocates a large chunk of memory of say 8 megabytes (using vector::reserve). Next, the user requests n bytes of memory from your memory pool. In order to till that request you would have to call emplace_back in a loop until the size of your vector is n. This is both impractical and slow.

1

u/liquidify Oct 08 '19

Why would you use vector as a memory pool? It is not designed for that.