On Saturday, 8 December 2012 at 11:10:27 UTC, Namespace wrote:
Why this code compiles without Dtor, but not when I have one?

http://dpaste.dzfl.pl/2792b974

Reading compiler errors is a good idea:

(18-25):Error: function c739.Color.opAssign (Color p) is not callable using argument types (Color) const

Because you use didn't supply opAssign, default one is generated. It calls postblit and destructor for temporary. Once you define any of them, default opAssign cannot be const and because you assign static const structs in static constructor at lines 18-25, compiler issues errors.

Solution is to move initialization of static fields to compile time and use static struct initialization. In any case you know values of Black, Green, etc. so why would one initialize them at runtime? You can also turn them into enums.

http://dpaste.dzfl.pl/09572204

Reply via email to