Comparison chart of D and C++ templates
Kirk McDonald
kirklin.mcdonald at gmail.com
Sat Jan 20 13:09:46 PST 2007
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);
--
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org
More information about the Digitalmars-d-announce
mailing list