Reclamation (without finalization) at the end of the program
Our first implementation will provide reclamation but not finalization at the end of program execution. For this reason, it will not accept managing objects of some type T
if T
is not trivially destructible since objects of that type have a destructor that might have to be executed to avoid leaks or other problems along the way.
With this example, as with the others in this chapter, we will start with our test code, and then go on to see how the reclamation mechanics are implemented. Our test code will go as follows:
- We will declare two types,
NamedThing
andIdentifier
. The former will not be trivially destructible as its destructor will contain user code that prints out debugging information, but the latter will be, as it will only contain trivially destructible non-static data members and offer no user-provided destructor. - We will provide two
g()
functions. The first one will be commented out as it tries...