Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2005-12-09 04:47:13

----Original Message----
From: Peter Dimov [mailto:pdimov_at_[hidden]]
Sent: 08 December 2005 16:46
To: boost_at_[hidden]
Subject: Re: [boost] [boost::throw_exception] and platforms where
itdon't throw

> Martin Bonner wrote:
>> From: Peter Dimov [mailto:pdimov_at_[hidden]]
>>> And of course in a situation where throw_exception is used to throw
>>> bad_alloc, an assertion makes even less sense, because there are no
>>> "logic errors" involved, and presenting the effects of a failed
>>> assertion to the end user would serve little purpose; the program
>>> could do nothing to defend itself from the out of memory situation.
>> But if a library is being used in an exception free environment,
>> maybe presenting an assertion failure to the user is as good as you
>> can do.
> Possibly, but who is "you" in the above sentence?
The library author.

> The whole point of using an exception is that you the library
> author do not take responsibility of handling the error, leaving
> it up to you the library user to do that instead.
Right. But the problem is what does the author of boost::whatever do when
the user wants to use boost::whatever in an environment that doesn't support

One solution is to offer two functions (like at() and operator[]) and the
user who doesn't want exceptions uses the no-throw function.

That's a good solution sometimes, but there are other occasions where adding
all that extra machinery to support the few no-throw users is a bit much.
In those circumstances, it may be better for boost::whatever to say "if your
environment supports exceptions, you can handle condition x by catching y;
if not, condition x will crash your program." The no-throw users may decide
they know condition x is not going to happen, or that crashing is OK, or
that they can't use the library. At least that way the users get to choose.

Martin Bonner
Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ,
ENGLAND Tel: +44 (0)1223 441434

Boost list run by bdawes at, gregod at, cpdaniel at, john at