From: Nicola Musatti (Nicola.Musatti_at_[hidden])
Date: 2006-07-31 03:36:32
Sorry for this late answer, I've just got back from vacation.
Paul A Bristow wrote:
> If you have an array of 'fallible' data (measurements say), not all of which
> are valid,
> you can use doubles for the data, but you need an extra byte for each value
> hold the valid/not valid bit - a bool in a byte, or more perhaps.
> If you manage to persuade the compiler to pack the doubles and bytes
> the double won't be on speed-friendly boundaries,
> or if you don't/can't pack each byte, the bool may end up taking as much
> space as the double.
> So for a few items, fallible is fine, but for hundreds and up, has a
> A NaN by contrast is neatly stored in the double, and costs nothing extra,
> and MAY be used to indicate 'fallibility'.
> But don't let this make you too tired to continue - there are other cases
> when fallible may be very useful.
One solution to this problem is to supplement fallible<T> with a trait
indicating whether an in-range invalid value is available and its value
(an even more obvious example than NaN's is fallible<T *>).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk