Boost logo

Boost :

From: John Torjo (john_at_[hidden])
Date: 2003-05-08 06:49:20


> Darren Cook wrote:
> >
> > In my own assert library I added options for logging, but in the end
> > never used that and always had it throw an exception. This is nice for
> > two reasons:
> > 1. MFC debugger catches it and allows me to go back up the call stack
> > to where the assert happened. (I'm still struggling with gdb but I think
> > it can be set to do the same?)
> >
>
> Under win32, my assert method uses
>
> if (IsDebuggerPresent())
> {
> DebugBreak(); // ammounts to int 3 on intel
> }
>
> (IsDebuggerPresent() is a win32 method to see if a debugger is attached
> to the process)
>
> which I find better than the debugger catching an exception. At my last
> work place, we made asserts through exceptions but ended up with
> exceptions being thrown in destructors and such which wasn't very nice,
> especially if the destructor was being called during clean up because of
> a previous exception.
>

Indeed, you're right. Also, I don't prefer throwing exceptions by default.
But, it's very simple to do so, if this is what you want.

Best,
John


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