|A small subset of RM dealing
with heap resources makes garbage collection unnecessary. Realistically,
auto_ptr provides adequate transfer policy.
|Since auto_ptr is a
template, we canít really follow the First Rule of Acquisition. Instead of
allocating the resource in its constructor, we allocate it
|ē as an expression passed directly to auto_ptr constructor
|ē as an expression that is the argument to reset
|To transfer the ownership we
pass auto_ptr by value to and from functions.
|Note: Donít pass auto_ptr by
referenceóitís confusing. If you donít want to pass ownership, get the
pointer from auto_ptr and pass it around.
|auto_ptr<Foo> foo (new
|UseFoo (foo.get ()); // no