|
Boost : |
Subject: Re: [boost] [Root Pointer] Benchmark
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-03-15 21:07:58
On Tue, Mar 15, 2016 at 8:58 PM, Phil Bouchard <philippeb8_at_[hidden]> wrote:
>
> Yes you're right. I need to make my references const.
>
[snip]
>
> Thanks for the clarifications.
No problem. Remember the goal isn't to provide convoluted interfaces
that are strange to people who are used to a simpler convention
established in the C++ standard library (or Boost, or any other
library that supports C++ allocator concepts).
The Allocator class template in the example you have is a valid C++
stateful allocator. Observe how it is used with existing C++ standard
library facilities that are allocator aware:
int c1 = 0, c2 = 0;
vector<char, Allocator<char> > v(Allocator<char>(c1, c2));
list<int, Allocator<int> > l(Allocator<int>(c1, c2));
function<void(int)> f(allocator_arg, Allocator<void>(c1, c2), [](int){ });
auto p = allocate_shared<double>(Allocator<double>(c1, c2), 1.5);
With your root_ptr, the interface for creation should be equally
simple. No temporaries required. No extremely long type definitions
required. And certainly no expressions that look like: new
(temporary) Type(temporary, ...) (i.e. an expression that looks like
'temporary' is both the subject of the placement-new and an argument
to the constructor of Type).
Glen
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk