Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-08-17 09:54:02


At 05:56 PM 8/15/2001, Ross Smith wrote:

>"David A. Greene" wrote:
>>
>> Beman Dawes wrote:
>>
>> > Comments? Anyone like to try to put together a preliminary list of
>> > libraries?
>>
>> As a user of these libraries, I'd agree with others that smart_ptr
>> should be submitted.
>
>I disagree. shared_ptr is an early part of Boost that could use
>revisiting before any attempt to standardise it. More specifically, have
>a look at the policy-based smart pointers Andrei Alexandrescu describes
>in _Modern C++ Design_. After you've explored the possibilities of
>policy-based templates, I don't think you'll be satisfied with a
>one-size-fits-all design.

Actually, I've spent a huge amount of time and effort understanding and
experimenting with alternatives to the Boost and standard library smart
pointers, and still believe they are the best choice for standardization as
of today. I've looked at both generative and policy based approaches.
Performed generative experiments. Invented a notation to be able to
communicate and reason about smart pointer features. Read Andrei's book.
Attended his ACCU presentation. Discussed policy-based smart pointers with
him. Went over pros and cons again with Greg Colvin and Kevlin Henney at
the April C++ meeting. Emailed with Bjarne and Jeremy Siek about adding
named template parameters to the core language.

This last point has to do with my view that current smart pointer
policy-based designed are lumping too many features into each policy
(probably to reduce the number of policy parameters in the hope of
simplifying the interface). The rule of thumb I use is that each
additional parameter eliminates half the remaining users. True named
template parameters could reduce that cost, since adding a single policy at
the end of the list would no longer require supplying all the intermediate
arguments.

Anyhow, the FAQ entry still stands. It has been updated slightly since the
last release, and currently reads:

Q. Why doesn't shared_ptr have template parameters supplying traits or
policies to allow extensive user customization?

A. Parameterization discourages users. Shared_ptr is carefully crafted to
meet common needs without extensive parameterization. Someday a highly
configurable smart pointer may be invented that is also very easy to use
and very hard to misuse. Until then, shared_ptr is the smart pointer of
choice for a wide range of applications. (Those interested in policy based
smart pointers should read Modern C++ Design by Andrei Alexandrescu.)

--Beman


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