|
Boost : |
From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2000-05-30 19:11:18
--- In boost_at_[hidden], "Milutin Jovanovic" <miki_at_o...> wrote:
> Hmm, I have never faced the need for 15, let alone 20 different
smart
> pointers. If the number is this high in some projects, then I
agree, the
> appeal of separate implementations fades rather quickly.
Yes, 15 pointers in the same project might be the case only for
really large ones.
My point, however, is a bit different: if you need to develop a new
smart pointer from scratch just because you need an assert before
dereferencing and your smart pointer library doesn't do it, that's
not good.
So a library that indeed aims at providing useful smart pointer
classes should provide a lot of flexibility, in addition to providing
pre-canned implementations of the most common cases. But you never
can predict all the cases - special allocators, custom exceptions,
you name it.
SmartPtr makes a big effort not to let developers down when they have
to implement a smart pointer that **only slightly** particular, as it
most often happens. "I want a smart pointer that throws a
PointerException if you dereference the null pointer!" The smart
pointers of today offer only closed behavior, or a collection of
closed behaviors. With SmartPtr you can intervene and change many
aspects of it, while relying on the tried and true defaults in other
aspects. You don't have to cope with all the issues at once.
Andrei
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk