Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-09-13 03:22:16


On Friday 13 September 2002 09:38, Kresimir Fresl wrote:
> Toon Knapen wrote:
> > the bounds checking mechanism throws an exception instead of performing
> > an assert. But I have no clue how I can ask my debugger where the
> > exception was thrown so I would prefer an assert() to be used. In the
> > debugger, it's then easy to perform a stack_trace.
>
> Did you try to define BOOST_NO_EXCEPTIONS ?

This indeed would give me the behaviour I want as also redefining throw with
a macro (as Peter suggested).

Setting BOOST_NO_EXCEPTIONS however (which changes the semantics of the
program) just for catching my out-of-bounds-error is a little drastic.
It does indeed abort on the out-of-bouds error but the rest of my code that
might rely on exceptions also changes and thus is not an optimal solution.

Using the macro as Peter suggested also has this global effect (changes the
behaviour of _all_ exceptions) and I always get uncomfortable with macros.

Therefor my suggestion to just put an assert() just before the throw point.
Both in debug mode and release mode it exactly does what I want, provide me a
stack-trace in debug mode and throw an exception in release mode while not
affecting any other part of the program.

toon


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