From 65c3f2dc859669732b03f0e93f7c660876642440 Mon Sep 17 00:00:00 2001
From: Beman Dawes Introduction Class shared_ptr stores a pointer to a dynamically allocated
object. (Dynamically allocated objects are allocated with the C++ new
expression.) The object pointed to is guaranteed to be deleted when
@@ -33,7 +41,7 @@ object A dangling with a use_count() of 1. The class is a template parameterized on T, the type of the object
pointed to. T must meet the smart pointer Common
requirements.
+Class
shared_ptr
+Synopsis
+Members
+Example
+Handle/Body Idiom
+Frequently Asked Questions
+Smart Pointer TimingsIntroduction
Class shared_ptr Synopsis
+Class shared_ptr Synopsis
#include <boost/smart_ptr.hpp>
namespace boost {
@@ -112,7 +120,7 @@ than supplying a full range of comparison operators (<, >, <=, >=).<
name BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION is defined.
The current implementation does not supply the member template functions if the macro name BOOST_NO_MEMBER_TEMPLATES is defined.
-typedef T element_type;
Provides the type of the stored pointer.
@@ -218,19 +226,25 @@ which uses a shared_ptr<> to an incomplete type to hide the implementation. The instantiation of member functions which require a complete type occurs in the shared_ptr_example2.cpp implementation file. -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.
Q. Why doesn't shared_ptr use a linked list implementation?
+A. A linked list implementation does not offer enough advantages to
+offset the added cost of an extra pointer. See timings
+page.
Q. Why don't shared_ptr (and the other Boost smart pointers)
supply an automatic conversion to T*?
A. Automatic conversion is believed to be too error prone.
Revised 24 May, 2001 +
Revised 12 July, 2001
© Copyright Greg Colvin and Beman Dawes 1999. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright