Variadic Struct Parameter

Q. Schroll qs.il.paperinik at gmail.com
Tue Jan 12 17:46:14 UTC 2021


On Tuesday, 12 January 2021 at 17:26:15 UTC, Jonathan Levi wrote:
> Why is this not working?
>
> ```
> struct S {
>     int x;
>     string y;
> }
>
> void fun(S s ...) {

This is intended for arrays and classes, not structs. Using ... 
for something other than arrays and c

>     fun(S(5,"hi"));

That one should compile...

>     fun(5,"hi");

and the second one not.

It's obvious why arrays work, it's the primary use case. I have 
no idea why classes are allowed. That classes are allowed, but 
structs are not, makes no sense to me.


More information about the Digitalmars-d-learn mailing list