Boost logo

Boost :

Subject: Re: [boost] [Root Pointer] Benchmark
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-03-15 23:29:07


On Tue, Mar 15, 2016 at 10:50 PM, Phil Bouchard wrote:
> Ok sorry for the delay but it's fixed now:
>
[snip]
> typedef boost::node<U, Allocator<U> > node;
>
> boost::root_ptr<U> p1;
>
> p1 = node::allocate(node::allocator_type(n1, m1), 1, 'a');

1. Your other examples won't compile (e.g. your benchmark.cpp), as you
have found out, with these changes, for the obvious reason(s) - e.g.
requiring allocator to provide construct/destroy (which a conforming
allocator does not have to do in C++11 and above).

2. You should be rebinding to value_type to construct() the value type
object (in the same way to you rebind to node type to allocate() node
type object). Likewise for destroy().

3. Surely:

    p1 = node<U, Allocator<U> >::allocate(node<U, Allocator<U>
>::allocator_type(x, y), p, q)

   can become simpler still. i.e. the target is still something as clean as:

    p1 = allocate_shared<U>(Allocator(x, y), p, q);

4. No 'const_cast'-ing away 'const'. You need to use the allocators correctly.

Glen


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk