From: David Abrahams (dave_at_[hidden])
Date: 2003-07-22 07:25:22
Daniel Spangenberg <dsp_at_[hidden]> writes:
> David Abrahams schrieb:
>> Well, that's not my philosophy FWIW. Mine is:
>> if the condition is a programmer error, use assert
>> otherwise, use a well-documented exception
>> Occasionally, due to a "no throw" requirement, you have to choose to
>> make certain things into programmer errors that would not otherwise
>> be, but those conditions should be *very rare*.
> I did not want to imply, that this is **your** opinion. Sorry, for the
> induced misunderstanding.
> Just two points I would like to mention:
> 1) The above given definition practically makes the exception family
> based on logic_error useless.
Right! At least, for debugging, that is.
> This is even documented in the Our Standard. 19.1.1/p. 1 says: "The
> class logic_error defines the type of objects thrown as exceptions
> to report errors presumably detectable before the program executes,
> such as violations of logical preconditions or class invariants."
I don't have to support the use of everythning that's written in "Our
Standard", do I <wink>?
> 2) For what kind of errors should be BOOST_ASSERT for? My
> assumption is, it is for what you name "programmer error". If so,
> shouldn't it actually provide the throw() guarantee? I think, many of
> you would like to kill me for this proposal ;-), but for me it seems like
> a natural conclusion.
Actually, it's fine for BOOST_ASSERT to throw something like
logic_error in some kinds of production programs which need to keep
running and are "likely" to be able to recover if an exception is
thrown. What's usually not OK is the idea of throwing logic_error in
a debug version of a program.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk