Boost logo

Boost :

Subject: Re: [boost] [Root Pointer] Benchmark
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2016-03-15 20:40:44

On Tue, Mar 15, 2016 at 8:31 PM, Phil Bouchard wrote:
> Well first if you have a as an r-value:
> p = g<X>(a, args...)
> That means the allocator parameter must be constant:
> g<X>(Allocator const &, arg...)
> If it's constant it won't be able to change its internal state. I thought
> that was the purpose of having instantiable allocators?

I think you do not understand the allocator model. 'const A&' is fine
for the allocator argument.

std::vector<T, A>'s constructors have a 'const A&' parameter.
std::allocate_shared<T, A, Args...> takes a 'const A&' parameter.
std::function's function<A> constructor takes a 'const A&' parameter.

All of the above copy-initialize an A instance from the given
parameter, and would thus have a non-const A instance on which to call
allocate(), et cetera.

The way that the stateful allocators would be designed is such that
they all reference the same shared state (similar to 'Allocator' in
that example.cpp I gave you).


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