CT Inheritence structures
Enamex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 19 23:28:47 PDT 2016
On Saturday, 20 August 2016 at 00:46:15 UTC, Engine Machine wrote:
> I am trying to get Timon Gehr's code working, with some
> modifications:
>
> void main()
> {
>
> import std.traits;
>
> auto a = new Type!("Animal", "Dog", "Pug")();
> Type!("Animal", "Dog") b = a;
> Type!("Animal") c = b;
>
> a.s = 1;
> b.z = 2;
> c.y = 3;
> }
>
Also:
alias T1 = TemplateOf!(typeof(a));
alias T2 = TemplateOf!(typeof(c));
pragma(msg, "\n", T1!"As", " -- ", T2!"As", "\n"); // T1!"As"
-- T1!"As"
That's extremely weird. It looks like template instantiations
carry as their printable name (and comparison identifier, because
`is(templateAlias == templateAlias2)` doesn't work) the name they
were first instantiated through.
So even doing:
pragma(msg, T1!("Animal", "Dog"))
would print `PT!("Animal", "Dog")` given that it had been
instantiated already through another Type with ("Animal", "Dog")
in the beginning of its tuple.
More information about the Digitalmars-d-learn
mailing list