Where are the template members?
deadalnix
deadalnix at gmail.com
Wed Dec 5 15:15:45 PST 2012
On Wednesday, 5 December 2012 at 08:39:12 UTC, Gor Gyolchanyan
wrote:
> 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)?
The compiler should yell at you ! what you try to do here make no
sense :D
More information about the Digitalmars-d
mailing list