From eb3d3464db44072655f6a01f8540d782b51a1e0d Mon Sep 17 00:00:00 2001
From: Peter Dimov shared_ptr is now part of TR1, the first C++
Library Technical Report. The latest draft of TR1 is available
at the following location: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1745.pdf (1.36Mb
- PDF) http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1745.pdf
+ (1.36Mb PDF) This implementation conforms to the TR1 specification, with the only exception
that it resides in namespace Throws: nothing. Notes: Allows shared_ptr objects to be used as keys in
associative containers.boost
instead of std::tr1
.Best Practices
@@ -402,7 +402,7 @@ q = p;
!(a
< b) && !(b < a)
, two shared_ptr instances
- are equivalent if and only if they share ownership.
If your program is single-threaded and does not link to any libraries that might have used shared_ptr in its default configuration, you can #define the macro BOOST_SP_DISABLE_THREADS on a project-wide basis to switch to ordinary non-atomic reference count updates.
-(Defining BOOST_SP_DISABLE_THREADS in some, but not - all, translation units is technically a violation of the One Definition - Rule and undefined behavior. Nevertheless, the implementation attempts to do - its best to accommodate the request to use non-atomic updates in those - translation units. No guarantees, though.)
+(Defining BOOST_SP_DISABLE_THREADS in some, but not all, + translation units is technically a violation of the One Definition Rule and + undefined behavior. Nevertheless, the implementation attempts to do its best to + accommodate the request to use non-atomic updates in those translation units. + No guarantees, though.)
You can define the macro BOOST_SP_USE_PTHREADS to turn off the - lock-free platform-specific implementation and fall back to the generic - pthread_mutex_t-based code.
+ lock-free platform-specific implementation and fall back to the generic pthread_mutex_t-based + code.Q. There are several variations of shared pointers, with different tradeoffs; why does the smart pointer library supply only a single diff --git a/weak_ptr.htm b/weak_ptr.htm index 3fcdcb7..e214d4a 100644 --- a/weak_ptr.htm +++ b/weak_ptr.htm @@ -145,9 +145,8 @@ template<class Y> weak_ptr & operator=(shared_ptr<Y> const &
long use_count() const;
-Returns: 0 if *this is empty; otherwise, - the number of shared_ptr objects that share ownership - with *this.
+Returns: 0 if *this is empty; otherwise, the + number of shared_ptr objects that share ownership with *this.
Throws: nothing.
Notes:
@@ -189,7 +188,7 @@ template<class Y> weak_ptr & operator=(shared_ptr<Y> const &use_count()
is not necessarily efficient. Use only for debugging and testing purposes, not for production code.under the equivalence relation defined by operator<, + are equivalent if and only if they share ownership or are both empty.!(a < b) && !(b < a)
, two weak_ptr instances - are equivalent if and only if they share ownership.Throws: nothing.
Notes: Allows weak_ptr objects to be used as keys in associative containers.