> Some time ago, when we were first discussing smart_ptr, it was >mentioned here that someone had identified 36 different styles of >smart pointers. > > Could anyone here point me to that article?
That may have been a reference to a feature model I started, but never really finished. See attached.
It generated over 100 different configurations. I expect that if you finished it with features like weak_ptr and others that Peter Dimov and others have developed, you would end up with thousands or tens of thousands of valid configurations.
--Beman
Title: Smart Pointer Feature Diagram
Smart Pointer Feature Model DiagramThe purpose of the memory management smart pointer concept is to hold a C++ built-in pointer and to manage its memory ownership. A smart pointer is a an example of the "resource acquisition is initialization" technique described by Stroustrup in "The C++ Programming Language" [14.4.1]. In a larger sense, smart pointers are not limited to memory management. Other roles they can play include checking, locking, loading, and navigation. Most iterators in the standard library are examples of smart pointers even though they don't have strong ownership semantics. The feature model presented here focuses only on memory management design features. For more information about feature diagrams, see www.boost.org/more/feature_model_diagrams.htm. Feature DiagramMemory-management-smart-pointer( ownership, shape, allocation, deletion, type-visibility, conversion-to-ptr )
To ease implementation, array is not allowed with attached-reference-count, but there are no other constraints. This feature diagram generates over 100 valid configurations. Most, if not all, of those configurations are actually useful in practical applications. ownershipThe most fundamental feature of a memory management smart pointer is how the ownership of the pointed-to memory is managed.
shapeallocation
deletion
type-visibilityC++ language rules [ISO 5.3.5] require that the type being deleted by a delete-expression be either a complete type or have a trivial destructor [ISO 12.4].
conversion-to-ptr
AcknowledgementsPortions of this discussion are based on boost mailing list postings by Kevlin Henney. The format for this page was patterned after Jeremy Siek's Mutex Feature Diagram page. Revised 13 Oct 2000 © Copyright Beman Dawes, 2000 |
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost