On Mon, Mar 14, 2016 at 7:13 PM, Phil Bouchard
On 03/14/2016 12:53 PM, Glen Fernandes wrote:
You should only have to modify lines [45, 48].
i.e. Changing "shared_ptr" to "root_ptr" and changing "allocate_shared" to your mechanism of constructing your root pointer.
This won't compile out of the box because I need to comment: - node<>::static_pool() - node<>::operator new - node<>::operator delete
But if you comment out the aforementioned functions then the following will work without throwing anything: https://github.com/philippeb8/root_ptr/blob/master/example/allocator.cpp
Comment out what from where? More simply, if someone wants to use
root_ptr with a conforming C++ allocator (such as Allocator<T> in that
example) what must they do?
e.g. With shared_ptr they would use allocate_shared:
shared_ptr<int> p1 = allocate_shared<int>(Allocator<int>(state));
e.g. With vector they would just use the constructor:
vector
From the code that you showed, it looks like for block_ptr, they would need to do: nodealloc<int>::PoolType a1(state); root_ptr<int> p1 = new(a1) nodealloc<int>(a1);
But first they need to define the nodealloc class template?! That doesn't seem right. What happens if they want to pass constructor parameters as well? struct T { T(int, char, bool) { } }; auto p1 = std::allocate_shared<T>(Allocator<T>(state), 5, 'g', false); How would they do that with root_ptr? Would they have to define a new nodealloc class template to do it? Glen