CT Inheritence structures

Engine Machine via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 20 12:30:31 PDT 2016


On Saturday, 20 August 2016 at 06:28:47 UTC, Enamex wrote:
> 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.

So I guess this method simply won't work ;/ Or somehow TypeParent 
will have to construct the proper type indirectly, which may be 
impossible ;/ I'll try and work on it a little and see what 
happens.




More information about the Digitalmars-d-learn mailing list