Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Requirements for a handle

We present in this chapter the concept of a handle to an object of type T. Basically a handle to an object of type T behaves like a pointer to an object of type T except that it has no increment nor decrement operators and does not deal with memory allocation or deallocation. Essentially a handle has two operators * and -> which gives access to the object pointed to.

Types

typedef T value_type;

Creation

Handle<T> ht;
ht references no object.

Handle<T> ht ( hr);
copy constructor

Handle<T> ht ( T* pt);
constructs a reference from a pointer T*.

Handle<T>& ht = T* pr ht points to the object *pr
Handle<T>& ht = pr ht and pr point to the same object.

Dereference

T& * ht returns the object pointed to.
T* ht -> returns a pointer to the object pointed to.

Equality

bool ht == hr true if ht and q reference the same object.
bool ht != hr true if ht and hr reference distinct objects.


Next: Class declaration of Pointer<T>
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The GALIA project. Jan 18, 2000.