Boost logo

Boost :

From: David Bradley (dbradley_at_[hidden])
Date: 2003-01-17 16:25:04


David Abrahams wrote:

>It's truly amazing how many problems are solved by the existing
>boost::shared_ptr<> design, and it's a big advantage to have a
>single-source smart pointer which "just works" in so many ways.
>There's so much to learn about what it's capable of that many people
>legitimately believe more parameterization would harm
>understandability.
>
>
>
A number of years ago we used a policy based smart pointer class. Worked
really well. Allowed us to easily choose between intrusive and passive
ref counts, as well as incorporate thread safe vs non-thread safe
versions and easily use the type of smart pointer we needed for the task
at hand all with the same interface and familiarity. Not to mention that
once we got the basic implementation right, adding new policies was a
breeze.

We received some resistance from some developers claiming it was too
complex. But in my view, if you don't want to look inside, the typedefs
are simple enough, just use them. It's just like the rest of the STL
that is quite complex, but people use it.

If one fear this, then why would they not fear std::string and
std::wstring. Both those represent more complex templates. They each
could have been implemented as a class, "simplifying" the
implementation. Granted it's not a great analogy, but I don't think a
policy based smart pointer is that much different.

David Bradley
dbradley_at_[hidden]


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