Comparison chart of D and C++ templates
janderson
askme at me.com
Sat Jan 20 16:02:39 PST 2007
Kirk McDonald wrote:
> janderson wrote:
>> Walter Bright wrote:
>>
>>> janderson wrote:
>>>
>>>> Walter Bright wrote:
>>>>
>>>>> http://www.digitalmars.com/d/template-comparison.html
>>>>>
>>>>> Comments?
>>>>
>>>>
>>>> What about automatic induction? You probably want to link to a
>>>> reason why D doesn't have it (since it will probably be questioned
>>>> again and again). You could also mention how aliasing can go some
>>>> way to solving this difference.
>>>
>>>
>>> What is automatic induction?
>>
>>
>>
>> Sorry, I mean like:
>>
>> template <class C>
>> void Get(C& c) {}
>>
>> ...
>> int X = 0;
>> Get(X);
>>
>> float Y = 0;
>> Get(Y);
>>
>> No need to specify the types.
>>
>
> That is implicit function template instantiation, and D *does* have it.
>
> void Get(C)(C c) {}
>
> int X = 0;
> Get(X);
>
> float Y = 0;
> Get(Y);
>
Cool. I didn't realize that D now supports that. So why not put these
some examples on the webpage instead of just "Yes"?
-Joel
More information about the Digitalmars-d-announce
mailing list