diff --git a/shared_ptr.htm b/shared_ptr.htm index 4e5f561..809ceb3 100644 --- a/shared_ptr.htm +++ b/shared_ptr.htm @@ -16,7 +16,8 @@ Handle/Body Idiom
Thread Safety
Frequently Asked Questions
- Smart Pointer Timings

+ Smart Pointer Timings
+ Programming Techniques

Introduction

The shared_ptr class template stores a pointer to a dynamically allocated object, typically with a C++ new-expression . The object pointed to is @@ -390,8 +391,8 @@ q = p; many of the implicit conversion pitfalls.

[The conversion to bool is not merely syntactic sugar. It allows shared_ptrs - to be declared in conditions when using dynamic_pointer_cast or - weak_ptr::lock.]

+ to be declared in conditions when using dynamic_pointer_cast + or weak_ptr::lock.]

swap

void swap(shared_ptr & b); // never throws
diff --git a/smart_ptr.htm b/smart_ptr.htm index ddf5e39..9327c9f 100644 --- a/smart_ptr.htm +++ b/smart_ptr.htm @@ -68,6 +68,8 @@ versions of the smart pointer implementation.

A page on smart pointer timings will be of interest to those curious about performance issues.

+

A page on smart pointer programming techniques lists + some advanced applications of shared_ptr and weak_ptr.

Common Requirements

These smart pointer class templates have a template parameter, T, which specifies the type of the object pointed to by the smart pointer. The behavior diff --git a/sp_techniques.html b/sp_techniques.html index e523a52..a157f0b 100644 --- a/sp_techniques.html +++ b/sp_techniques.html @@ -1,12 +1,12 @@ - Smart pointer programming techniques + Smart Pointer Programming Techniques

c++boost.gif (8819 bytes)Smart - pointer programming techniques

+ Pointer Programming Techniques

Using incomplete classes for implementation hiding
The "Pimpl" idiom
Using abstract classes for implementation hiding
@@ -615,7 +615,10 @@ public:

Note that shared_lock is not templated on the mutex type, thanks to shared_ptr<void>'s ability to hide type information.

Using shared_ptr to wrap member function calls

-

[http://www.research.att.com/~bs/wrapper.pdf]

+

shared_ptr implements the ownership semantics required from the Wrap/CallProxy + scheme described in Bjarne Stroustrup's article "Wrapping C++ Member Function + Calls" (available online at http://www.research.att.com/~bs/wrapper.pdf). + An implementation is given below:

template<class T> class pointer
 {
 private:
@@ -631,7 +634,7 @@ public:
     shared_ptr<T> operator->() const
     {
         p_->prefix();
-        return shared_ptr<T>(p_, mem_fn(&T::suffix));
+        return shared_ptr<T>(p_, mem_fn(&T::suffix));
     }
 };