Boost logo

Boost :

Subject: Re: [boost] [Root Pointer] Benchmark
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-03-14 20:12:50

On Mon, Mar 14, 2016 at 7:13 PM, Phil Bouchard <philippeb8_at_[hidden]> wrote:
> 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:

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<int, Allocator<int> > v1(Allocator<int>(state));

e.g. With function they would just use the constructor:
    function<void()> f1(allocator_arg, Allocator<void>(state));

>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?


Boost list run by bdawes at, gregod at, cpdaniel at, john at