Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to get it working in boost 1.69 #2

Merged
merged 1 commit into from Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions eos/portable_iarchive.hpp
Expand Up @@ -66,7 +66,7 @@
* in binary floating point serialization as desired by some boost users.
* Instead we support only the most widely used IEEE 754 format and try to
* detect when requirements are not met and hence our approach must fail.
* Contributions we made by Johan Rade and �kos Mar�y.
* Contributions we made by Johan Rade and Ákos Maróy.
*
* \note Version 2.0 fixes a serious bug that effectively transformed most
* of negative integral values into positive values! For example the two
Expand Down Expand Up @@ -117,6 +117,10 @@
#elif BOOST_VERSION < 104800
#include <boost/spirit/home/support/detail/integer/endian.hpp>
#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
#elif BOOST_VERSION >= 106900
#define BOOST_MATH_DISABLE_STD_FPCLASSIFY
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/endian/conversion.hpp>
#else
#include <boost/spirit/home/support/detail/endian/endian.hpp>
#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
Expand All @@ -125,13 +129,17 @@
// namespace alias
#if BOOST_VERSION < 103800
namespace fp = boost::math;
#elif BOOST_VERSION >= 106900
namespace fp = boost::math;
#else
namespace fp = boost::spirit::math;
#endif

// namespace alias endian
#if BOOST_VERSION < 104800
namespace endian = boost::detail;
#elif BOOST_VERSION >= 106900
namespace endian = boost::endian;
#else
namespace endian = boost::spirit::detail;
#endif
Expand Down Expand Up @@ -350,7 +358,11 @@ namespace eos {

// load the value from little endian - it is then converted
// to the target type T and fits it because size <= sizeof(T)
t = endian::load_little_endian<T, sizeof(T)>(&temp);
#if BOOST_VERSION >= 106900
t = endian::little_to_native(temp);
#else
t = endian::load_little_endian<T, sizeof(T)>(&temp);
#endif
}

else t = 0; // zero optimization
Expand Down
25 changes: 20 additions & 5 deletions eos/portable_oarchive.hpp
Expand Up @@ -69,7 +69,7 @@
* in binary floating point serialization as desired by some boost users.
* Instead we support only the most widely used IEEE 754 format and try to
* detect when requirements are not met and hence our approach must fail.
* Contributions we made by Johan Rade and �kos Mar�y.
* Contributions we made by Johan Rade and Ákos Maróy.
*
* \note Version 2.0 fixes a serious bug that effectively transformed most
* of negative integral values into positive values! For example the two
Expand Down Expand Up @@ -120,6 +120,10 @@
#elif BOOST_VERSION < 104800
#include <boost/spirit/home/support/detail/integer/endian.hpp>
#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
#elif BOOST_VERSION >= 106900
#define BOOST_MATH_DISABLE_STD_FPCLASSIFY
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/endian/conversion.hpp>
#else
#include <boost/spirit/home/support/detail/endian/endian.hpp>
#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
Expand All @@ -128,13 +132,17 @@
// namespace alias fp_classify
#if BOOST_VERSION < 103800
namespace fp = boost::math;
#elif BOOST_VERSION >= 106900
namespace fp = boost::math;
#else
namespace fp = boost::spirit::math;
#endif

// namespace alias endian
#if BOOST_VERSION < 104800
namespace endian = boost::detail;
#elif BOOST_VERSION >= 106900
namespace endian = boost::endian;
#else
namespace endian = boost::spirit::detail;
#endif
Expand Down Expand Up @@ -328,8 +336,11 @@ namespace eos {

// we choose to use little endian because this way we just
// save the first size bytes to the stream and skip the rest
endian::store_little_endian<T, sizeof(T)>(&temp, t);

#if BOOST_VERSION >= 106900
temp = endian::native_to_little(temp);
#else
endian::store_little_endian<T, sizeof(T)>(&temp, t);
#endif
save_binary(&temp, size);
}
// zero optimization
Expand Down Expand Up @@ -387,10 +398,14 @@ namespace eos {
switch (fp::fpclassify(t))
{
//case FP_ZERO: bits = 0; break;
case FP_NAN: bits = traits::exponent | traits::mantissa; break;
#if BOOST_VERSION >= 106900
case FP_NAN: bits = traits::exponent | traits::significand; break;
#else
case FP_NAN: bits = traits::exponent | traits::mantissa; break;
#endif
case FP_INFINITE: bits = traits::exponent | (t<0) * traits::sign; break;
case FP_SUBNORMAL: assert(std::numeric_limits<T>::has_denorm); // pass
case FP_ZERO: // note that floats can be 0.0
case FP_ZERO: // note that floats can be ±0.0
case FP_NORMAL: traits::get_bits(t, bits); break;
default: throw portable_archive_exception(t);
}
Expand Down