Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-07-12 15:02:01


At 03:52 AM 7/12/2001, Christian Thäter wrote:

>Uh .. in copying containers which involve alot of temponary objects the
>single-linked list is really worse, forget it. I modified my code to a
>double linked list and get better results than the boost::shared_ptr .
Well
>the most noteable point was my need about the shared semantics which
isn't
>possible with a refcounting scheme. Eh, sorry i didn't seen at my first
look
>that there is also a "Smart Pointer Timings" page which covers most of
the
>performance topics. My code is now similar to the linked_ptr example. It
>will get some attach() and detach() interface to link/unlink it from some

>pointer-set.

This comes up enough that I've added a FAQ entry:

   Q. Why doesn't shared_ptr use a linked list implementation?
   A. A linked list implementation does not offer enough advantages
      to offset the added cost of an extra pointer. See timings page.

I've also added a reference to one of the other FAQ entries:

   (Those interested in policy based smart pointers should read Modern
   C++ Design by Andrei Alexandrescu.)

If you look at the Smart Pointer Timings
http://www.boost.org/libs/smart_ptr/smarttests.htm, the real questions are:

Why haven't we added an allocator to shared_ptr?

Why haven't we proposed an invasive_shared_ptr?

While there are some technical issues, I'm afraid part of the answer is
simple inertia. And of course shared_ptr as it now stands is plenty good
enough for the majority of uses.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk