<div><span class="" style="white-space:pre">Consider this piece of code:</span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre"> </span>struct Test</div><div><span class="" style="white-space:pre"> </span>{</div>
<div><span class="" style="white-space:pre"> </span>template member(Type)</div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre"> </span>Type member;</div><div><span class="" style="white-space:pre"> </span>}</div>
<div><span class="" style="white-space:pre"> </span>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>unittest</div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre"> </span>Test test;</div>
<div><span class="" style="white-space:pre"> </span>test.member!int = 0;</div><div><span class="" style="white-space:pre"> </span>test.member!long = 0;</div><div><span class="" style="white-space:pre"> </span>test.member!short = 0;</div>
<div><span class="" style="white-space:pre"> </span>import std.stdio; writeln(test.sizeof);</div><div><span class="" style="white-space:pre"> </span>assert(test.sizeof == int.sizeof + long.sizeof + short.sizeof); // fails</div>
<div><span class="" style="white-space:pre"> </span>assert(test.sizeof == 1); // succeeds</div><div><span class="" style="white-space:pre"> </span>}</div><div><br></div><div>I don't get why the structure's size remains unchanged even after instantiating 3 members inside it.</div>
<div>How can I get the real size of the structure, including all its members (template or not)?</div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>