Why Templates?
Sean Kelly
sean at f4.ca
Sat Mar 4 18:10:23 PST 2006
Walter Bright wrote:
> "Sean Kelly" <sean at f4.ca> wrote in message
> news:duda9o$137k$1 at digitaldaemon.com...
>> is a bit annoying and reduces readability. ITI is also quite useful in
>> C++ with respect to how overload resolution is handled, but I have no idea
>> how this will translate to the far simpler overloading rules in D. I think
>> we really may have to simply want and see what Walter comes up with for
>> ITI in D, as simply eliminating the need to explicitly specify template
>> parameters doesn't encompass the full utility of ITI in C++. Will we be
>> able to overload template functions with each other?
>
> Yes.
>
>> Will they also overload with non-template functions?
>
> No. This is a misfeature in C++, and the equivalent can be done with
> explicitly specialized template functions.
Cool. I feel pretty much the same.
>> What happens if there are multiple matches?
>>
>> class C(T) {}
>>
>> template func(T) { void func( T val ) {} }
>> template func(T) { void func( C!(T) val ) {} }
>> void func( C!(int) val ) {}
>>
>> func( new C!(int) );
>>
>> In C++, this is legal and the result is clearly defined (the "most
>> specialized" overload is called), but how will this translate to D?
>
> It'll be the most specialized.
Very nice :-) Yet more to look forward to!
Sean
More information about the Digitalmars-d
mailing list