Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1998-12-06 10:11:18


In Santa Cruz, we talked about smart pointer classes; a simple no
transfer-of-ownership flavor called "scoped_ptr" (previously
"safe_ptr") and a referenced counted flavor called "shared_ptr"
(previously counted_ptr).

Greg Colvin and I have about completed work on these, but have a
problem we would like other's opinions on:

Greg has two implementations (with identical interfaces) of
shared_ptr:

   (1) An "direct" version which privately holds the T* and a pointer
to a reference counter on the heap.

   (2) An "indirect" version which privately holds a single pointer
to a heap allocated struc which contains the T* and reference
counter.

It would seem that the direct version will generate less code and run
faster for dereferencing, and more code and run slower for argument
passing and returns.

It would seem that the indirect version will generate more code and
run slower for dereferencing, and less code and run faster for
argument passing and returns.

Tests on a 200-Mhz Pentium Pro don't show significant differences in
speed, however.

What should we do:

   * Pick one implementation? If so, which one? (Greg's preference.)
   * Supply both with different names? What are good names, then?

--Beman

------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com


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