Smart Pointer Feature Model Diagram

The 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 Diagram

Memory-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. 

ownership

The most fundamental feature of a memory management smart pointer is how the ownership of the pointed-to memory is managed.

shape

allocation

deletion

type-visibility

C++ 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

Acknowledgements

Portions 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