Boost logo

Boost :

Subject: Re: [boost] [Root Pointer] Benchmark
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-03-15 19:25:09


On Tue, Mar 15, 2016 at 7:02 PM, Phil Bouchard wrote:
> Ok I fixed it and the code will look like the following:
>
[snip]
> {
> typedef boost::node<U, Allocator<U> > node;
> typedef typename node::allocator_type allocator_type;
>
> boost::root_ptr<U> p1, p2, p3;
>
> allocator_type a1(n1, m1);
> p1 = new (a1) node(a1, 1, 'a');
>

Hi Phil,

I'll be able to check it out and reply further once I get home, but
while I'm still in transit: The first thing that stands out as
concerning is:

Compared to a very simple:
    p = allocate_shared<T>(instance, args...);

Your pointer type requires:
    boost::node<U, Allocator<U> >::allocator_type a(instance);
    p = new (a) boost::node<U, Allocator<U> >(a, args...);

Before we even get into potentially undesirable implementation
mechanics of 'node' there, the above is clearly not intuitive or
clean. i.e. Why can't it even be written as a single:
    p = [expression involving 'a', and 'args...'];

You mentioned a while back that you preferred: p.reset(new
X(args...)); because it was intuitive, and in your opinion more
intuitive than: p = f<X>(args...);

Nobody would have any issue with that. But people would certainly have
issue with: Y::Z b(a); p = new (b) Q(b, args...); compared to p =
g<X>(a, args...);

Glen

Glen


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