assert(obj) is a mystery
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Wed Nov  9 02:33:14 PST 2011
    
    
  
On Tuesday, November 08, 2011 21:51:46 Davidson Corry wrote:
> OK. Not addressing Alex's objections at all, it's not clear to me why
> anyone would *need* to test the invariant of an object.
I wouldn't expect it to be something that you'd need to do very often. 
However, if you give access to the member variables in your class or struct - 
either directly or indirectly - allowing code outside the type to modify that 
type's state, then the invariant can be violated. Now, it's arguably bad 
design to allow such access when using an invariant (if not in general), but 
it _is_ a case where the invariant can be invalidated.
- Jonathan M Davis
    
    
More information about the Digitalmars-d-learn
mailing list