<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Helvetica, Arial, sans-serif">In TableGen, there is
the following struct. In any given instance, only one of the
pointers is filled in.</font></p>
<blockquote>
<p><tt> struct RecordsEntry {<br>
std::unique_ptr<Record> Rec;<br>
std::unique_ptr<ForeachLoop> Loop;<br>
std::unique_ptr<Record::AssertionTuple> Assertion;<br>
<br>
void dump() const;<br>
<br>
RecordsEntry() {}<br>
RecordsEntry(std::unique_ptr<Record> Rec) :
Rec(std::move(Rec)) {}<br>
RecordsEntry(std::unique_ptr<ForeachLoop> Loop)<br>
: Loop(std::move(Loop)) {}<br>
RecordsEntry(std::unique_ptr<Record::AssertionTuple>
Assertion)<br>
: Assertion(std::move(Assertion)) {}<br>
};<br>
</tt></p>
</blockquote>
<p>It has been suggested that the three pointers be made a union.
This requires a discrimination enum. I believe that would reduce
the struct from 24 to 12 bytes, and I think it requires a custom
destructor.</p>
<p>What do people think about this? If I should do it, could someone
help me with the changes?<br>
</p>
<div class="moz-signature">
<br>
</div>
</body>
</html>