Allow auto in function parameters with default arguments?

Timon Gehr timon.gehr at gmx.ch
Mon Sep 10 06:44:04 PDT 2012


On 09/10/2012 06:20 AM, Andrej Mitrovic wrote:
> It occurred to me that using a parameter with a default value that is
> a function call could benefit from using auto:
>
> struct Foo(T) { }
>
> auto getFoo()
> {
>      return Foo!int();
> }
>
> void func(int x, auto foo = getFoo()) { }
>
> Granted this is a simple case and might be overkill,

As parameter names are optional, foo is parsed as the parameter type in
this case. What exact change do you propose?

> but if the function returns some complicated range type (or worse, a Voldemort
> type) it might be hard or impossible to specify the type.
>

Every type that you can get hold of a value of can be specified by the 
means of typeof.


More information about the Digitalmars-d mailing list