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 as a pointer to an object of type T, except that it has no increment or decrement operators. A handle has two operators * and ->, which give 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*.

Operations

Handle<T>& ht = T* pr ht points to the object *pr
Handle<T>& ht = pr ht and pr points to the same object.
void ht.clear () sets ht to reference no object.

Dereference

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

Memory allocation

void ht.Delete () deallocates the memory referenced by ht.

Equality

bool ht.is_null () true if ht references no object.
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 CGAL_Pointer<T>
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. 22 January 1999.