[Proposal] "Name inference" for function templates
Bruno Medeiros
brunodomedeirosATgmail at SPAM.com
Sat Jun 17 12:16:58 PDT 2006
Markus Dangl wrote:
> Andrei Khropov schrieb:
>> I think retyping the same name twice for function templates is not a very
>> natural way, so I propose omitting the template name if there's only a
>> single
>> declaration in the template's body and then this declaration's name is
>> "inferred " for subsequent use, i.e. :
>> ------------------------------------------------
>> template sqr(T)
>> {
>> T sqr( T x )
>> {
>> return x*x;
>> }
>> }
>> ------------------------------------------------
>
> http://www.digitalmars.com/d/template.html
> If there's only a single declaration, you can even write:
>
> T sqr(T) ( T x )
> {
> return x*x;
> }
>
> Which is already in the language and even shorter than your proposal ;)
> This is the same for class templates.
"You found a Secret!"
Hehe..
I didn't think that would work either.
--
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list