What is the case against a struct post-blit default constructor?

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 12 00:36:10 PDT 2012


On Friday, October 12, 2012 07:53:09 monarch_dodra wrote:
> Yes, as answered, opAssign may do things to this, such as
> dealocate a payload, reduce a ref counter, or who knows what.

A valid point, but it would be easy to explicitly call the invariant at the 
beginning of opAssign if wanted to ensure that the object's state was valid at 
the beginning of opAssign. You can't _not_ call the invariant though if the 
compiler already does. And there's another problem which your suggest against 
init suggestion wouldn't fix. It's initializing to void:

S s = void;

If you ever want to do that, you can't have an invariant, or it'll blow up 
when you try and assign to it. And since it certainly wouldn't be the same as 
the init property, checking against the init property wouldn't help you any.

- Jonathan M Davis


More information about the Digitalmars-d mailing list