Boost logo

Boost :

From: Dave Steffen (dgsteffen_at_[hidden])
Date: 2006-05-26 18:32:45


Pedro Lamarão writes:
> Maarten Kronenburg escreveu:
> > Gerhard,
> > Negating an unsigned_integer that is
> > not zero is like taking the square root
> > from a negative value, or dividing
> > an integer by zero:
> > an exception is thrown.
>
> Why introduce this C++ exception for "integer division by zero"?
> Why not simply allow the implementation to hit the corresponding
> hardware exception?

 FWIW, my $.02: there are two options.

 A) "Do as the ints do" (following Scott Meyers' advice), and hit
 hardware exceptions or specify some particular behavor; negating an
 unsigned int might be a no-op, or might generate some extremely large
 positive integer, or...

 B) "Do as we wish the ints did" and generate exceptions.

 I'd vote for A), not because I don't like exceptions, but because
 it's more consistent with the rest of the language, and also because
 there are situations where mathematical code needs to be _guaranteed_
 not to throw anything.

----------------------------------------------------------------------
Dave Steffen, Ph.D. Fools ignore complexity.
Software Engineer IV Pragmatists suffer it.
Numerica Corporation Some can avoid it.
ph (970) 419-8343 x27 Geniuses remove it.
fax (970) 223-6797 -- Alan Perlis
dgsteffen_at_[hidden]
___________________
Numerica Disclaimer:
This message and any attachments are intended only for the individual
or entity to which the message is addressed. It is proprietary and
may contain privileged information. If you are neither the intended
recipient nor the agent responsible for delivering the message to the
intended recipient, you are hereby notified that any review,
retransmission, dissemination, or taking of any action in reliance
upon, the information in this communication is strictly prohibited,
and may be unlawful. If you feel you have received this communication
in error, please notify us immediately by returning this Email to the
sender and deleting it from your computer.


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