Re: how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 4 July 2017 at 01:02:16 UTC, Era Scarecrow wrote: As soon as a class defines at least one constructor, the implicit default constructor is not avaliable anymore. - TDPL pg. 182 This is also true for structs, but one can't infer that from a rule about classes.

Re: how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d
On Tuesday, 4 July 2017 at 00:46:36 UTC, Timothee Cour wrote: How would I disable the following? ``` auto a1=A(1); auto a2=A(1, "b"); Disable the struct's default constructor, which implicitly disables struct literals for it [1]. --- struct A { int a; string b; @disable this();

Re: how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Era Scarecrow via Digitalmars-d
On Tuesday, 4 July 2017 at 00:46:36 UTC, Timothee Cour wrote: How would I disable the following? ``` auto a1=A(1); auto a2=A(1, "b"); struct A{ int a; string b; // @disable default constructors with N(N>=1) arguments } ``` I'd like to force the user to set fields explicitly, so as to ma

Re: how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Stefan Koch via Digitalmars-d
On Tuesday, 4 July 2017 at 00:46:36 UTC, Timothee Cour wrote: How would I disable the following? ``` auto a1=A(1); auto a2=A(1, "b"); struct A{ int a; string b; // @disable default constructors with N(N>=1) arguments } ``` I'd like to force the user to set fields explicitly, so as to ma

how to disable all default N-argument constructors for a struct?

2017-07-03 Thread Timothee Cour via Digitalmars-d
How would I disable the following? ``` auto a1=A(1); auto a2=A(1, "b"); struct A{ int a; string b; // @disable default constructors with N(N>=1) arguments } ``` I'd like to force the user to set fields explicitly, so as to make it more safe to add / move fields