From b60de38d28e804fa07f69b1589fc2087235937c9 Mon Sep 17 00:00:00 2001
From: Peter Dimov The smart pointer library includes five smart pointer class templates. Smart
-pointers ease the management of memory dynamically allocated with C++ new
-expressions. In addition, scoped_ptr can ease the management of memory
-dynamically allocated in other ways. Revised 1 February 2002. The smart pointer library includes five smart pointer class templates. Smart
+ pointers ease the management of memory dynamically allocated with C++ new
+ expressions. In addition, scoped_ptr can ease the management of memory
+ dynamically allocated in other ways. Revised
+ 1 February 2002 . The scoped_ptr template is a simple solution for simple needs. It
supplies a basic "resource acquisition is initialization" facility, without
shared-ownership or transfer-of-ownership semantics. Both its name and
- enforcement of semantics (by being
- noncopyable) signal its intent to retain ownership solely within the
- current scope. Because it is
- noncopyable,
+ enforcement of semantics (by being
+ noncopyable) signal its intent to retain ownership solely within the
+ current scope. Because it is noncopyable,
it is safer than shared_ptr or std::auto_ptr for pointers which
should not be copied. Because scoped_ptr is simple, in its usual implementation every operation
@@ -151,12 +150,12 @@ Buckle my shoe
One common usage of scoped_ptr is to implement a handle/body (also called
pimpl) idiom which avoids exposing the body (implementation) in the header
file. The scoped_ptr_example_test.cpp sample
- program includes a header file, scoped_ptr_example.hpp,
+ The scoped_ptr_example_test.cpp sample
+ program includes a header file, scoped_ptr_example.hpp,
which uses a scoped_ptr<> to an incomplete type to hide the
implementation. The instantiation of member functions which require a complete
- type occurs in the scoped_ptr_example.cpp implementation
- file.
-
-
-
-
- Home
- Libraries
- People
- FAQ
- More
- Smart Pointer Library
-
-
-
-
+
+
+
+
+ Home
+ Libraries
+ People
+ FAQ
+ More
+ Smart Pointer Library
+
+
+
Q. Why doesn't scoped_ptr have a release() member?
A. When reading source code, it is valuable to be able to draw
@@ -166,11 +165,12 @@ Buckle my shoe
given context. Use std::auto_ptr where transfer of ownership
is required. (supplied by Dave Abrahams)
Revised 09 January 2003
+Revised + 09 January 2003
Copyright 1999 Greg Colvin and Beman Dawes. Copyright 2002 Darin Adler. Copyright 2002 Peter Dimov. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.