Boost logo

Boost :

From: Ross Smith (ross.s_at_[hidden])
Date: 2001-09-04 18:38:00

Jens Maurer wrote:
> boost_at_[hidden] wrote:
> > 2 Arguments
> >
> > Many need checks on validity of arguments.
> > For example, probability p must be 0 <= p <= 1.
> >
> > What should I do after the check fails?
> > throw standard exception out_of_range?
> That's often a longish debate. Documented preconditions
> (such as the allowed input range) are sometimes checked with
> "assert". That halts the program on failure. However, I think
> for the maths functions, I'd rather see an exception instead
> of an assert(), because it's very tedious to check all
> preconditions in longish expressions.

There needs to be a way to tell the library (at compile time) to skip
the checks, because this sort of library is likely to be used in highly
compute-bound contexts where checking beforehand that all initial values
are in a known stable region of the problem space, and then running the
whole thing with no further checking, can be an order of magnitude
faster than checking along the way. If you insist on checking all
function arguments, you lose a lot of potential users.

Remember Kanze's Law: You can build a safe library on top of an
efficient one, but not the other way around.

Ross Smith .......................................... ross.s_at_[hidden]
Ihug (Auckland, New Zealand) ...................
+++ Divide by cucumber error - Please reinstall universe and reboot +++

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