Disabling struct destructor illegal?
RazvanN
razvan.nitu1305 at gmail.com
Thu Jul 19 10:04:34 UTC 2018
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
>> annotated with @disable
>>
>> I was expecting that disabling the destructor would make it as
>> if the struct does not have a destructor
>
> Why? That's not the semantics of @disable. And why would you
> want that? What are you actually trying to achieve?
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?
More information about the Digitalmars-d-learn
mailing list