Syntax sugar for {} with structs
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Jul 2 16:15:13 UTC 2022
On Saturday, 2 July 2022 at 15:00:41 UTC, Nick Treleaven wrote:
> On Saturday, 2 July 2022 at 13:59:39 UTC, Ola Fosheim Grøstad
> wrote:
>> if D wants to do this then the compiler should type {} as a
>> parameter list.
>
> A parameter list of zero parameters?
>
> ```d
> struct S{}
>
> void f();
> void f(S s);
>
> f({}); // which gets called?
> ```
It is a parameter list for the constructor of S, so `F(S s)` gets
called.
More information about the Digitalmars-d
mailing list