Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization]Nans and infinity in wide xml archive
From: Elizabeta (elizabeta.petreska_at_[hidden])
Date: 2017-07-04 09:48:06


Hi Robert
I did template specialization of basic_text_iprimitive::load for double, and
it works with visual studio 2010 compiler. Do you see something problematic
with this code

namespace boost {
    namespace archive {
        template<> template<>
        void basic_text_iprimitive< std::basic_istream<wchar_t,
std::char_traits&lt;wchar_t>> >::load<double>(double& t)
        {
            if (!is.fail())
            {
                std::wstring s;
                getline(is, s, L'<');
                is.putback(L'<');

                int index = s.find(L"IND");
                if (index != -1)
                {
                    t = std::numeric_limits<double>::quiet_NaN();
                    return;
                }

                index = s.find(L"NAN");
                if (index != -1)
                {
                    t = std::numeric_limits<double>::quiet_NaN();
                    return;
                }

                index = s.find(L"INF");
                if (index != -1)
                {
                    t = std::numeric_limits<double>::infinity();
                    return;
                }

                t = std::stod(s);
                return;
            }

            boost::serialization::throw_exception(
                archive_exception(archive_exception::input_stream_error)
                );
        }
}
}

--
View this message in context: http://boost.2283326.n4.nabble.com/serialization-Nans-and-infinity-in-wide-xml-archive-tp4696397p4696451.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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