Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-08 03:22:36


Hartmut Kaiser wrote:
> Dan W. wrote:
>>B) I want the debugger to stop execution at the line in which
>>the violated expression is coded; not in some other place
>>from which I have to go back in the stack to see what happened.
> BTW you can tell almost any debugger to stop, if/when any (given) exception
> is thrown.

Wasn't aware of it, thanks. However, I'd still rather not use exceptions
inside code meant for debugging; --they may not be enabled, and besides,
I think of exceptions as higher level than asserts; I'd rather use the
latter to debug the former, not the other way around. This invariants
implementation is meant to be at the level of asserts; in fact it IS
asserts.

I've simplified the code, following from Daniel Wallin's comments,

   Version 1.01 -- Jan 8, 2004
     * Put this documentation in separate text file (was comments
      in invariants.hpp; and added use example below.
     * Got rid of enabled_ state, and first_call/last_call, and
      changed to using private inheritance of invariants class.

I have NOT moved away from inheritance, however, as explained in
invariants.txt under 'Rationale':

------------------------------
   It's been suggested to me that introducing inheritance and
   virtual functions via inheritance in debug mode might not be
   good ideas. Note however that,
   (A) as of version 1.01 there is no longer size augmentation
      via inheritance, since the only data member was removed.
   (B) also as of version 1.01 private inheritance is used.
   (C) class invariants is templeted per derived, and therefore
      does not conduce to unwanted sibling relationships
   (D) the only virtual function inherited from invariants class
      is check_invariants(), which is pure virtual in the base,
      and no longer virtual in derived. This AFAIK should not
      cause the compiler to generate an otherwise absent virtual
      table.
   (E) Using inheritance allows one to use succint class member
      names in the invariant assertions, rather than have to
      dereference a pointer, or reference via '.'.
------------------------------

Cheers!




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk