diff --git a/shared_ptr.htm b/shared_ptr.htm index 2108b43..4913f65 100644 --- a/shared_ptr.htm +++ b/shared_ptr.htm @@ -252,9 +252,23 @@ complex project that turned out to have cyclic-dependencies.
A. Because complexity limit implementors and complicate the specification without apparent benefit to shared_ptr users. For example, error-checking implementations might become non-conforming if they had to meet stringent complexity requirements. +Q. Why doesn't shared_ptr provide a release() function?
+A. shared_ptr cannot give away ownership unless it's unique()
+because the other copy will still destroy the object.
Consider:
+++shared_ptr<int> a(new int); +shared_ptr<int> b(a); // a.use_count() == b.use_count() == 2 + +int * p = a.release(); + +// Who owns p now? b will still call delete on it in its destructor.+
[Provided by Peter Dimov]
Q. Why doesn't shared_ptr provide (your pet feature here)?
A. Because (your pet feature here) would mandate a reference counted (or a link-list, or ...) implementation. This is not the intent.
-[Provided by Peter Dimov]
+[Provided by Peter Dimov]
Revised 11 January, 2002