Safe pointers as function parameters

Safe pointer classes can help define interface semantics, when they are used as the type of formal parameters to a function, or the return value of a function. We advise programmers to follow these conventions:

The recipient of any kind of safe pointer may check the pointer for validity, and manipulate the object (if any) to which it points. In addition, the recipient of:

TAliasTo -- may retain a copy of the pointer. By CommonPoint programming convention, a raw pointer can also be used to declare such a interface. A raw pointer behaves similarly, and may be more efficient (if inlining is disabled, for example), but its ownership policy is less explicit.

TOnlyPointerTo -- may take ownership of the object, by copying the pointer into another TOnlyPointerTo. The owner must delete the object, eventually.

TInstanceOf -- may copy the object, by copying the pointer into another TInstanceOf; or take ownership of the object, by calling the pointer's Orphan() member function. Ownership may not be transferred if the pointer is const.

The following sections cover public interfaces to safe pointer class templates.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker