<div dir="ltr">Hi,<div><br></div><div>I have found the solution to my problem and posted it there:</div><div><a href="http://stackoverflow.com/questions/22203496/deserialization-of-non-finite-floating-point-numbers-fails-even-with-appropriate/22328343#22328343">http://stackoverflow.com/questions/22203496/deserialization-of-non-finite-floating-point-numbers-fails-even-with-appropriate/22328343#22328343</a><br>
</div><div><br></div><div>Christophe Fuzier</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-10 11:06 GMT+01:00 Christophe Fuzier <span dir="ltr">&lt;<a href="mailto:fuzierc@gmail.com" target="_blank">fuzierc@gmail.com</a>&gt;</span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have a problem with Boost.Serialization. I have posted a question on a forum but have not got any answer until now. Here is the reproduction of my post (note: I&#39;m using Boost 1.48, patch level 0).</div>

<div><br></div><div><p style="clear:both;vertical-align:baseline;line-height:17.804800033569336px;font-size:14px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;margin:0px 0px 1em;border:0px;padding:0px">

I need to use Boost.Serialization to serialize floating-point numbers. Since NaN and infinites cannot natively be read from an input stream, I am trying to use the facets in boost/math/special_functions. I have tested them on my platform using code similar to the examples we can find here:�<a href="http://www.boost.org/doc/libs/1_50_0/libs/math/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html" rel="nofollow" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(74,107,130);text-decoration:none" target="_blank">http://www.boost.org/doc/libs/1_50_0/libs/math/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html</a></p>

<p style="clear:both;vertical-align:baseline;line-height:17.804800033569336px;font-size:14px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;margin:0px 0px 1em;border:0px;padding:0px">
However, the following code still fails to properly unserialize non-finite floating point values (an exception is thrown with description &quot;input stream error&quot;).</p>#include &lt;limits&gt;<br>#include &lt;locale&gt;<br>

#include &lt;sstream&gt;<br><br>#include &lt;boost/archive/xml_iarchive.hpp&gt;<br>#include &lt;boost/archive/xml_oarchive.hpp&gt;<br>#include &lt;boost/math/special_functions/nonfinite_num_facets.hpp&gt;<br>#include &lt;boost/serialization/nvp.hpp&gt;<br>

<br>struct Data {<br>� � � � float f;<br><br>� � � � Data() : f(std::numeric_limits&lt;float&gt;::quiet_NaN()) {}<br><br>� � � � template &lt;class Archive&gt;<br>� � � � void serialize(Archive &amp; ar, unsigned const)<br>

� � � � {<br>� � � � � � � � ar &amp; BOOST_SERIALIZATION_NVP(f);<br>� � � � }<br>};<br><br>void test()<br>{<br>� � � � using namespace boost::archive;<br>� � � � Data d;<br>� � � � std::ostringstream oss;<br>� � � � xml_oarchive oar(oss);<br>

� � � � oar &lt;&lt; BOOST_SERIALIZATION_NVP(d);<br>� � � � //std::cout &lt;&lt; oss.str() &lt;&lt; std::endl;<br>� � � � std::istringstream iss(oss.str());<br>� � � � std::locale const new_loc(iss.getloc(), new boost::math::nonfinite_num_get&lt;char&gt;);<br>

� � � � iss.imbue(new_loc);<br>� � � � xml_iarchive iar(iss);<br>� � � � iar &gt;&gt; BOOST_SERIALIZATION_NVP(d);<br>� � � � std::cout &lt;&lt; d.f &lt;&lt; std::endl;<br>}</div><div><br><p style="clear:both;vertical-align:baseline;line-height:17.804800033569336px;font-size:14px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;margin:0px 0px 1em;border:0px;padding:0px">

Am I doing something wrong? Is there a problem with my Boost version or my platform? Is there a better solution? Any help would be greatly appreciated.</p><p style="clear:both;vertical-align:baseline;line-height:17.804800033569336px;font-size:14px;font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif;margin:0px 0px 1em;border:0px;padding:0px">

&lt;END OF POST&gt;</p></div><div>Thank you in advance for any suggestion.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Christophe Fuzier</div>
</font></span></div>
</blockquote></div><br></div>