Grizlyk said:
Either you are still misunderstanding how to use the wrapper, or I am
completely misunderstanding you.
In the post you linked to above, you state:
<quote>
I am repeating again - source of the exception is hardware (CPU), the
test (rhs.data == 0) _is not enough_.
</quote>
The test (rhs.data == 0) as used in Kai-Uwe Bux's wrapper class is
entirely necessary and entirely sufficient to prevent divide by zero
ever happening. It doesn't make divide by zero a safe thing to do. It
make it impossible for divide by zero to happen.
rhs.data is the divisor in the division we are *considering* carrying
out. Note, *considering*. At the point of testing whether rhs.data ==
0, we have not decided whether to do the division or not. If it turns
out that rhs.data is zero, we decide not to attempt the division *at
all* because we know it will cause a problem. Instead, we throw an
exception (a C++ exception).
Clearly, if we were to try and divide by rhs.data, that would be
division by zero, which would be bad. But the precise point of the
wrapper class is that, in the case that rhs.data is zero, *no division
is carried out*. A completely different course of action, with well
defined behaviour, is taken.
Gavin Deane