I am looking to implement a (double) linked list that only calls placement new internally, directing all the memory to a pool allocated with something like:
char *memPool = new char[4096];
Initially, I was going to implement my own class, which takes a pointer to a pool of allocated resources (the class that controls a). However, first I want to be sure that I cannot achieve the same result with std::list . In particular, the third part of David Rodriguez's answer to this SO question bothers me.
It makes sense that std::list will have to call new and delete on its component nodes, but I want to change this behavior so that all nodes are distributed with placement new in my user pool. So my question is:
Is it possible to indicate that a placement new std::list , for example:
std::list<std::shared_ptr<Cls>> myList = new (pool.getFreeAddr()) list<Cls>;
should also allocate its nodes using a custom allocator so that everything is kept strictly inside my own memory pool?
(Note: I am aware of the need to use custom allocation / deletion functions using shared_ptrs if I also want them in a custom memory pool.)
source share