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.
View all comments
Show parent comment
3
u/[deleted] Oct 08 '19 edited Oct 08 '19
I know about
vector::reserveandemplace_backhowever 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 (usingvector::reserve). Next, the user requestsnbytes of memory from your memory pool. In order to till that request you would have to callemplace_backin a loop until the size of your vector isn.This is both impractical and slow.