IceUtil::Handle implements a smart reference-counted pointer type. Smart pointers are used to guarantee automatic deletion of heap-allocated class instances. (See
Section 6.14.6 for a detailed explanation of smart pointers.)
Handle is a template class with the following interface:
1
The template argument must be a class that derives from Shared or
SimpleShared (or that implements reference counting with the same interface as these classes); see
page 1765 for a description of these classes.
This is quite a large interface, but all it really does is to faithfully mimic the behavior of ordinary C++ class instance pointers. Rather than discussing each member function in detail, we provide a simple overview here that outlines the most important points. Please see
Section 6.14.6 for more examples of how to use smart pointers.
These member functions allow you to construct, copy, and assign smart pointers as if they were ordinary pointers. In particular, the constructor and assignment operator are overloaded to work with raw C++ class instance pointers, which results in the "adoption" of the raw pointer by the smart pointer. For example, the following code works correctly and does not cause a memory leak: