Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1998-12-07 11:33:44

At 03:04 PM 12/6/98 -0800, Nathan Myers wrote:

>Beman Dawes writes:
> > Greg has two implementations (with identical interfaces) of
> > shared_ptr:
> >
> > (1) An "direct" version which privately holds the T* and a
> > to a reference counter on the heap.
> >
> > (2) An "indirect" version which privately holds a single
> > to a heap allocated struc which contains the T* and reference
> > counter.
> >
> > What should we do:
> >
> > * Pick one implementation? If so, which one? (Greg's
> > * Supply both with different names? What are good names,
>There is a third option: parameterize. [...]

Yes, it would be nice to be able to write:

  shared_ptr<MyClass> my_default_ptr; // direct_shared_ptr
  shared_ptr<MyClass, indirect> my_indirect_shared_ptr;
  shared_ptr<MyClass, embedded> my_embedded_shared_ptr;

That way people who didn't care use the default, others specify to
meet their needs. I don't know how to implement exactly that; the
only real implementation I have been able to figure out requires you
to write something messier.

Maybe the best solution is to provide:

  shared_ptr<MyClass> my_default_ptr; // direct
  indirect_shared_ptr<MyClass> my_indirect_shared_ptr;
  embedded_shared_ptr<MyClass> my_embedded_shared_ptr;

The last two names are longish, but most people will just use
shared_ptr so it probably doesn't matter.


Free Web-based e-mail groups --

Boost list run by bdawes at, gregod at, cpdaniel at, john at