This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::shared_ptr vs allocators: by value or by const ref?!?


On 8 October 2010 12:31, Paolo Carlini wrote:
> Hi all, hi Jon,
>
> does anybody know what the heck is going on about allocator passing? We
> have allocate_shared taking the allocator by const ref, whereas the
> constructors, at variance with the rest of the library AFAICS, ?take it
> by value. Then in our implementation, at variance with the current
> C++0x, shared_ptr::reset takes it by const ref only to pass it
> immediately to a by value constructor, also we internally use by const
> ref in many other places. For sure, I have been able to change our impl
> to consistently use by const ref everywhere and apparently nothing
> breaks, and I don't see why it should: when a mutable allocator is
> required it is always constructed in the body of the various functions
> from the argument. Is there an open DR about this, Jon?

I don't think so.  I have no idea why the shared_ptr constructors take
allocators by value.

The reset() inconsistency is probably my fault.  At one point I
experimented with passing them by reference, so maybe I missed that
one and it got committed.  I think I chose to pass by const-ref
internally, because I couldn't see any reason not to.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]