Re: Disabling struct destructor illegal?

2018-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/18 4:50 AM, RazvanN wrote: struct A {     int a;     @disable ~this() {} } void main() {     A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is annotated with @disable I was expecting that disabling the destructor would make it as

Re: Disabling struct destructor illegal?

2018-07-20 Thread Jim Balter via Digitalmars-d-learn
On Thursday, 19 July 2018 at 10:04:34 UTC, RazvanN wrote: On Thursday, 19 July 2018 at 09:50:32 UTC, Jim Balter wrote: On Thursday, 19 July 2018 at 08:50:15 UTC, RazvanN wrote: struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error:

Re: Disabling struct destructor illegal?

2018-07-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 19, 2018 10:04:34 RazvanN via Digitalmars-d-learn wrote: > I just don't understand why you would ever mark the destructor of > a struct with @disable. When is that useful? If it's not, why not > just forbit it? There's nothing special about destructors here. You can @disable any

Re: Disabling struct destructor illegal?

2018-07-19 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 19 July 2018 at 10:04:34 UTC, RazvanN wrote: I just don't understand why you would ever mark the destructor of a struct with @disable. When is that useful? If it's not, why not just forbit it? struct S1 { ~this() { /* stuff */ } } struct S2 { S1 s; @disable ~this(); }

Re: Disabling struct destructor illegal?

2018-07-19 Thread RazvanN via Digitalmars-d-learn
On Thursday, 19 July 2018 at 09:50:32 UTC, Jim Balter wrote: On Thursday, 19 July 2018 at 08:50:15 UTC, RazvanN wrote: struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is annotat

Re: Disabling struct destructor illegal?

2018-07-19 Thread Jim Balter via Digitalmars-d-learn
On Thursday, 19 July 2018 at 08:50:15 UTC, RazvanN wrote: struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is annotated with @disable I was expecting that disabling the destruct

Disabling struct destructor illegal?

2018-07-19 Thread RazvanN via Digitalmars-d-learn
struct A { int a; @disable ~this() {} } void main() { A a = A(2); } Currently, this code yields: Error: destructor `A.~this` cannot be used because it is annotated with @disable I was expecting that disabling the destructor would make it as if the struct does not have a destruct