Boost logo

Boost :

Subject: Re: [boost] [Root Pointer] Benchmark
From: Phil Bouchard (philippeb8_at_[hidden])
Date: 2016-03-16 17:35:34


On 03/15/2016 11:29 PM, Glen Fernandes wrote:
>
> 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);

I have simplified it and now it cannot be any simpler than the following
(using template template argument):

template<class T, class V = float>
class Allocator
{
[...]

int main()
{
     int n1 = 0, m1 = 0;
     int n2 = 0, m2 = 0;
     {
         boost::root_ptr<U> p1, p2, p3;
         p1 =
boost::allocate_node<U>(boost::make_node_allocator<Allocator, U>(n1,
m1), 1, 'a');
         p2 =
boost::allocate_node<U>(boost::make_node_allocator<Allocator, U,
double>(n2, m2), 2, 'b');
         p3 =
boost::allocate_node<U>(boost::make_node_allocator<Allocator, U, long
double>(n2, m2), 3, 'c');

         if (n1 != 1 || m1 != 1 || n2 != 2 || m2 != 2) {
             throw 3;
         }
     }
     if (n1 != 0 || m1 != 0 || n2 != 0 || m2 != 0) {
         throw 4;
     }
}

Or:
https://github.com/philippeb8/root_ptr/blob/master/example/allocator.cpp#L82

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

I took the const_cast<>s away.


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