How Different Are Templates from Generics

Just Dave abcdef at 1234.com
Fri Oct 11 18:09:20 UTC 2019


Thanks for the thorough explanation. Most of that is how I was 
thinking it worked. However, that leaves me perplexed. If 
templates just generate code then how come:

Wouldnt..

     class SomeClass(T) : ISomeInterface!T

and..

     class SomeOtherClass(T) : ISomeInterface!T

...generate two different interfaces? Two interfaces that do the 
same thing, but two interfaces nonetheless? I assume each type in 
D has some form of type id underlying everything, which wouldn't 
that make the follow:

     if (instance1 is ISomeInterface<int>)
     {
         Console.WriteLine("Instance1 is interface!");
     }

fail? Or is there some extra magic that is making it work with my 
experiments?


More information about the Digitalmars-d-learn mailing list