16 Mar
2016
16 Mar
'16
12:58 a.m.
On 03/15/2016 08:40 PM, Glen Fernandes wrote:
I think you do not understand the allocator model. 'const A&' is fine for the allocator argument.
Yes you're right. I need to make my references const.
std::vector
's constructors have a 'const A&' parameter. std::allocate_shared 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).
Thanks for the clarifications.