Boost logo

Boost Users :

From: Johan Råde (rade_at_[hidden])
Date: 2008-01-16 15:23:27


Ed Hill wrote:
> On Wed, 16 Jan 2008 13:09:17 -0500 Lorenzo Cavallaro wrote:
>> I'm trying to unserialize a boost::archive::text_iarchive. The
>> code used to work, but know (for no apparent reasons) it's calling
>> terminate throwing the following exception.
>>
>> terminate called after throwing an instance of
>> 'boost::archive::archive_exception what(): stream error
>> Aborted
>
>
> Hi Lorenzo,
>
> Under these circumstances:
>
> 1) classes contain float or double members
> 2a) [intentional] the floats/doubles are used to store
> NaN or +/-Inf values
> 2b) [unintentional] the floats or doubles are un-initialized
> and the memory they use just happens to contain (by
> circumstance) bit patterns for NaN or +/-Inf
>
> serialization to text or XML will "work" (that is, will run without
> errors) but de-serialization will result in stream errors since:
>
> double a;
> cin >> a;
>
> fails for "NaN", "Inf", etc.
>
> Ed

If the problem is the presence of infinity and NaN,
then you can solve the problem by using my Floating Point Utilities library.
It is available in the vault in folder Math - Numerics.
You need the facets in the header non_finite_num_facets.hpp.

It is not accepted into Boost yet, but the code is mature and has been tested
with more than 20 different operating system / compiler / processor combinations.

--Johan Råde


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net