Skip to content

Commit

Permalink
Use std::fpclassify instead of Boost.Math
Browse files Browse the repository at this point in the history
  • Loading branch information
tstenner committed Oct 15, 2023
1 parent a2b28ef commit c1d30d8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/portable_archive/portable_archive_includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,28 @@
#pragma once

// endian and fpclassify
// disable std::fpclassify because it lacks the fp_traits::bits classes
#define BOOST_MATH_DISABLE_STD_FPCLASSIFY
#include <boost/endian/conversion.hpp>
#include <boost/math/special_functions/fpclassify.hpp>

// generic type traits for numeric types
#include "portable_archive_exception.hpp"
#include <cmath>
#include <cstdint>
#include <type_traits>

namespace lsl {
/*template<typename T>
int fpclassify(T val) { return std::fpclassify(val); }*/
template<typename T>
int fpclassify(T val) { return std::fpclassify(val); }
using std::isfinite;
namespace detail {

template <typename T> struct fp_traits_consts {};
template <> struct fp_traits_consts<double> {
using bits = uint64_t;
static constexpr bits sign = (0x80000000ull) << 32, exponent = (0x7ff00000ll) << 32,
significand = ((0x000fffffll) << 32) + (0xfffffffful);
static void get_bits(double src, bits &dst) { std::memcpy(&dst, &src, sizeof(src)); }
static void set_bits(double &dst, bits src) { std::memcpy(&dst, &src, sizeof(src)); }

};
template <> struct fp_traits_consts<float> {
using bits = uint32_t;
Expand All @@ -132,12 +134,6 @@ template <typename T> struct fp_traits {
} // namespace detail
} // namespace lsl

namespace fp = lslboost::math;
namespace fp = lsl;
// namespace alias endian
namespace endian = lslboost::endian;

// hint from Johan Rade: on VMS there is still support for
// the VAX floating point format and this macro detects it
#if defined(__vms) && defined(__DECCXX) && !__IEEE_FLOAT
#error "VAX floating point format is not supported!"
#endif

0 comments on commit c1d30d8

Please sign in to comment.