Boost logo

Boost :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-02-08 18:04:01

--- In boost_at_y..., Ruslan Zasukhin <sunshine_at_p...> wrote:
> on 2/8/02 23:34, bill_kempf at williamkempf_at_h... wrote:
> > There's an infinite variety of smart pointers, and no one smart
> > pointer is better then another, it solely depends on your needs.
> > That's why there's interest in adding the Loki smart pointer to
> > Boost. Using policies, the Loki smart pointer allows for all of
> > these smart pointer varieties.
> Excuse me, I am new to this list.
> What is Loki smart pointer ?

It's the smart pointer that exists in the Loki library, as discussed
in the book "Modern C++ Design: Generic Programming and Design
Patterns Applied" by Andrei Alexandrescu (a book I'd highly recommend
reading, BTW). Andrei is currently working on submitting parts of
Loki to Boost, and there's been a fair amount of discussion of his
SmartPointer in particular.
> Don't you think that it is possible to write
> A) general template AS IS
> B) specialization for
> template<>
> shared_ptr<Sharable*>
> Which will use second class sharable that keep counter ?

Yes, but this isn't really a good compromise for general use (though
for your project it may be a good solution until we have a policy
based smart pointer like that from Loki). The reason is that it
requires not only an intrusive implementation, but also inheritance,
which can quickly lead to the diamond pattern inheritance problem. A
better intrusive implementation would only require the type to
provide an interface for handling the ref-counts. But detecting such
an interface with out inheritance isn't really possible, so you need
a policy design instead of simple template specialization.
In other words, your concerns aren't invalid, but there are better
solutions then the one you propose, and we expect to have such a
solution in Boost in the relatively near future.

Bill Kempf

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