The created wrapped pointer class o®ers no more functionality than any dump pointer. To add
some smartness to the code skeleton a strategy needs to be implemented. Before going into an
implementation some strategies will be discussed. The list of strategies is not complete but should
be su±cient for most applications.

Every strategy is entirely de¯ned by the characteristics of the assignment operators and the de-
structor. Let ptr1 and ptr2 be smart pointers. Possible strategies for ptr1 = ptr2 and reset()
are described for each strategy.

Scoped pointer

The scoped pointer is rarely used. It stores a pointer to a dynamically allocated object. The
object pointed to is guaranteed to be deleted, either on destruction of the scoped pointer, or
via an explicit reset(). The assignment ptr1 = ptr2 is forbidden. Since a scoped pointer is
noncopyable it is caved within its scope and cannot get out. It's safer than the reference counting
or ownership transfer pointers for pointers which should not be copied.
Example: A local object (e.g. a class member) should be protected from being accidently passed
to the outside of the class scope.

Copied pointer

The copied pointer stores a pointer to a dynamically allocated object that is guaranteed to be
deleted on destruction of the copied pointer or via explicit reset(). The assignment ptr1 =
ptr2 creates a new copy of the object pointed by ptr2, and let ptr1 point to this copy. Creating
the new copy can be done with memcpy() (for plain old data (POD), like any C primitive) or by
using some "clonable" concept (for user de¯ned types (UDT), like C++ classes), which has to be
implemented by the element type.
Example: The copied pointer can be used whenever stack semantics are needed but the object
can not be created on the stack for some reason.
Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates