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 if the
struct does not have a destructor, instead it makes the program not
compile.
That's a misunderstanding of @disable. @disable *defines* the function,
and makes it uncallable.
If you want a struct without a destructor, just don't define one. Or if
you want one that eliminates the default destructor (in the case where
you have members with dtors), define an empty destrutor.
-Steve