Some more template syntax sugar

Kristian kjkilpi at gmail.com
Mon Aug 28 08:25:07 PDT 2006


On Mon, 28 Aug 2006 15:18:04 +0300, Reiner Pope  
<reiner.pope at REMOVE.THIS.gmail.com> wrote:
> I think function templates still require too much in the way of type  
> annotations. Take the canonical example, sqr:
>
> T sqr(T) (T x)
> {
> 	return x*x;
> }
>
> In this example, we have to declare T three times, even though I think  
> this could be inferred. I propose an alternative syntax:
>
> auto sqr(x)
> {
> 	return x*x;
> }
>
> which IMHO looks very elegant.
[snip]

It looks nice to me too.



More information about the Digitalmars-d mailing list