<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"><<a href="mailto:fuzierc@gmail.com" target="_blank">fuzierc@gmail.com</a>></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'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,'Liberation Sans','DejaVu Sans',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,'Liberation Sans','DejaVu Sans',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 "input stream error").</p>#include <limits><br>#include <locale><br> #include <sstream><br><br>#include <boost/archive/xml_iarchive.hpp><br>#include <boost/archive/xml_oarchive.hpp><br>#include <boost/math/special_functions/nonfinite_num_facets.hpp><br>#include <boost/serialization/nvp.hpp><br> <br>struct Data {<br>� � � � float f;<br><br>� � � � Data() : f(std::numeric_limits<float>::quiet_NaN()) {}<br><br>� � � � template <class Archive><br>� � � � void serialize(Archive & ar, unsigned const)<br> � � � � {<br>� � � � � � � � ar & 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 << BOOST_SERIALIZATION_NVP(d);<br>� � � � //std::cout << oss.str() << std::endl;<br>� � � � std::istringstream iss(oss.str());<br>� � � � std::locale const new_loc(iss.getloc(), new boost::math::nonfinite_num_get<char>);<br> � � � � iss.imbue(new_loc);<br>� � � � xml_iarchive iar(iss);<br>� � � � iar >> BOOST_SERIALIZATION_NVP(d);<br>� � � � std::cout << d.f << std::endl;<br>}</div><div><br><p style="clear:both;vertical-align:baseline;line-height:17.804800033569336px;font-size:14px;font-family:Arial,'Liberation Sans','DejaVu Sans',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,'Liberation Sans','DejaVu Sans',sans-serif;margin:0px 0px 1em;border:0px;padding:0px"> <END OF POST></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>