1
tt(Data)'s destructor has a data member which is an unrestricted union. As the
2
union's destructor can't perform any actions, the union's proper destruction
3
is delegated to a member, tt(Union::destroy) destroying the fields for which
4
destructors are defined. As tt(d_tag) stores the currently used tt(Union)
5
field, tt(Data)'s destructor can pass tt(d_tag) to tt(Union::destroy) to
6
inform it about which field should be destroyed.
8
tt(Union::destroy) does not need to perform any action for tt(INT) tags, but
9
for tt(STRING) tags the memory allocated by tt(u_string) must be returned. For
10
this an explicit destructor call is used. tt(Union::destroy) and
11
tt(Data)'s destructor are therefore implemented like this:
13
void Data::Union::destroy(Tag myTag)
15
if (myTag == Tag::STRING)
21
d_union.destroy(d_tag);