|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-08-22 11:38:14
Johan Råde wrote:
> 3. Formatting always succeeds.
Hmmm - formatting a NaN results in something like "+inf". Personally, I
wouldn't characterize that as a success.
<snip>
> This makes it difficult to implement strict_num_put.
> What should it do when validation fails?
> It can not set the failbit of the stream.
> The only thing it can do, is to throw an exception.
> The stream will catch that exception and set the badbit!
> At least with VC++ 7.1.
Its better than nothing. Personally I would be fine with this.
> Why? The stream probably assumes that formatting facets do not throw
> exceptions,
> so it concludes that the exception was thrown by the stream buffer.
> When the stream buffer is corrupted, the stream sets the badbit.
> However, setting the badbit when data validation fails, is a bad idea.
How come?
>
> Suggested solution:
> Throw out the facets strict_num_put and strict_num_get.
>
> Comments?
You've already investigated the issue more than I have so I'm happy to defer
to your judgement.
On the other hand, the attempt to serialize a NaN is an indication of a
broken program I would like to see it trapable. On the other hand, it seems
that I'm the only one who thinks this. Oh well.
>
> The documentation of the library has been updated to reflect this
> problem.
thanks for taking this on.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk