This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::shared_ptr vs allocators: by value or by const ref?!?
On 10/08/2010 02:29 PM, Paolo Carlini wrote:
> By the way, I reported our current status incorrectly / incompletely:
> our shared_ptr constructors also already use const ref. The only
> exception is allocate_shared and the __shared_ptr stuff. Thus, we have
> definitely to do something in v3, very likely just change everything to
> const ref. I have the straightforward patch ready.
>
In the meanwhile Alberto Ganesh Barbati pointed out on the reflector
that given move semantics it makes a lot of sense performance-wise to
have pass-by-value for object which are going to be copied very soon
anyway. Thus, unless somebody proposes to consistently change *the rest
of the library* to use pass-by-value for allocators, I mean to minimally
restore consistency in our implementation to everywhere pass-by-value
for shared_ptr + of course a few std::move (which are missing now) to
move from temporaries and actually exploit move semantics when possible
(allocators in C++0x are move-constructible with no throw guarantee anyway).
Paolo.