Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-01-13 09:29:54


--- Martin Bonner <martin.bonner_at_[hidden]> wrote:

> ----Original Message----
> From: Chris Cleeland
>
> > On Fri, 13 Jan 2006, Christopher Kohlhoff wrote:
> >
> >> Some thoughts, both for and against:
> >>
> >> - Does unsigned char always imply 0..255?
> No.

So it seems that if asio is going to provide this constructor,
then even if it uses unsigned char values there is the
possibility (on some platforms) of out of range values.

What should happen then if an out of range value is passed? The
choice is between:

- Silently changing the values to something in the range 0..255.

- Throwing an exception (using boost::throw_exception of course,
  so that platforms that lack exceptions can use another way of
  handling the error).

Whichever method is used, for a program to operate correctly it
should range-check the values before passing them to the
constructor.

If a well-behaved program is going to do that anyway, what is
the objection to using the exception approach? A well-behaved
program will never trigger the exception. If you forget to
range-check the values then you probably do want to know about
it.

Cheers,
Chris


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