Jonathan M Davis:
> With things being put in the pre-
> constructor state by clear(), it's not as obvious what's going on when things 
> go 
> wrong. Ideally, you'd want things to blow up when such an object was used, 
> with 
> it clearly indicating that it was because you used an object which isn't 
> supposed to exist anymore.

If you want the "failfast" (http://en.wikipedia.org/wiki/Failfast ) system, 
then you can use the last bit of the monitor or virtual table pointer to store 
store a boolean that denotes the cleared state of the object. This free space 
is not available for structs allocated on the heap, dynamic arrays, etc, and 
then you have to test this bit (in nonrelease mode only?) often, this slows 
down code a little.

Bye,
bearophile

Reply via email to