From 9dcbc46225216a2e7bc35b5cca263357f5ead7d7 Mon Sep 17 00:00:00 2001
From: Peter Dimov Because scoped_ptr is simple, in its usual implementation every operation
is as fast as for a built-in pointer and it has no more space overhead that a
built-in pointer. scoped_ptr cannot be used in C++ Standard Library
- containers. Use shared_ptr if you need
- a smart pointer that can. scoped_ptr cannot be used in C++ Standard Library containers.
+ Use shared_ptr if you need a smart pointer
+ that can. scoped_ptr cannot correctly hold a pointer to a dynamically
allocated array. See scoped_array for
that usage. Q. Why doesn't scoped_ptr have a release() member?
A. When reading source code, it is valuable to be able to draw
conclusions about program behavior based on the types being used. If scoped_ptr
- had a release() member, it would become possible to transfer ownership out of
- its scope, weakening its role as a way of limiting resource lifetime to a given
- scope. Use std::auto_ptr where transfer of ownership is
- required. (supplied by Dave Abrahams)
Revised 17 September 2002