Re: Typesafe variadic argument taking struct

2016-10-20 Thread Meta via Digitalmars-d-learn
On Thursday, 20 October 2016 at 14:29:53 UTC, Satoshi wrote: Oh, really? I didn't notice that... (sarcasm) If I change struct Foo to class Foo it works. It's because for some weird reason, this type of varargs allows implicit construction of an object. I don't know why, it's just a feature

Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
On Thursday, 20 October 2016 at 16:04:00 UTC, Nordlöw wrote: On Thursday, 20 October 2016 at 12:48:34 UTC, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Being explicit about these things makes complex code

Re: Typesafe variadic argument taking struct

2016-10-20 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 20 October 2016 at 12:48:34 UTC, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Being explicit about these things makes complex code more clear.

Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
On Thursday, 20 October 2016 at 12:52:42 UTC, rikki cattermole wrote: On 21/10/2016 1:48 AM, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Because an int is not a Foo. Oh, really? I didn't notice that...

Re: Typesafe variadic argument taking struct

2016-10-20 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 1:48 AM, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Because an int is not a Foo.

Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42);