Return type deduction

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 6 07:21:26 PDT 2016


On 9/5/16 5:59 AM, Andrea Fontana wrote:
> I asked this some time (years?) ago. Time for a second try :)
>
> Consider this:
>
> ---
>
> T simple(T)() { return T.init; }
>
>
> void main()
> {
>     int test = simple!int(); // it compiles
>     int test2 = simple();    // it doesn't

       auto test3 = simple!int();

Granted, you are still typing "auto", but only specify the type once.

-Steve


More information about the Digitalmars-d mailing list