Skip to content

Commit

Permalink
Updated to get it working in boost 1.69
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmotiongestures committed Jul 29, 2019
1 parent 6c515f3 commit b0047fc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
16 changes: 14 additions & 2 deletions eos/portable_iarchive.hpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit b0047fc

Please sign in to comment.