Where are the template members?

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Wed Dec 5 00:39:00 PST 2012


Consider this piece of code:

struct Test
{
template member(Type)
{
Type member;
}
}

unittest
{
Test test;
test.member!int = 0;
test.member!long = 0;
test.member!short = 0;
import std.stdio; writeln(test.sizeof);
assert(test.sizeof == int.sizeof + long.sizeof + short.sizeof); // fails
assert(test.sizeof == 1); // succeeds
}

I don't get why the structure's size remains unchanged even after
instantiating 3 members inside it.
How can I get the real size of the structure, including all its members
(template or not)?

-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121205/25063260/attachment.html>


More information about the Digitalmars-d mailing list