Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/multiprecision/complex_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ inline void eval_set_real(complex_adaptor<Backend>& result, const T& arg)
}

template <class Backend>
inline std::size_t hash_value(const complex_adaptor<Backend>& val)
constexpr std::size_t hash_value(const complex_adaptor<Backend>& val)
{
std::size_t result = hash_value(val.real_data());
std::size_t result2 = hash_value(val.imag_data());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ inline int eval_fpclassify(const number_backend_float_architype& arg)
return BOOST_MP_FPCLASSIFY(arg.m_value);
}

inline std::size_t hash_value(const number_backend_float_architype& v)
inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const number_backend_float_architype& v)
{
std::hash<long double> hasher;
std::hash<long double> hasher { };

return hasher(v.m_value);
}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/cpp_bin_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ int eval_signbit(const cpp_bin_float<D1, B1, A1, E1, M1, M2>& val)
}

template <unsigned D1, backends::digit_base_type B1, class A1, class E1, E1 M1, E1 M2>
inline std::size_t hash_value(const cpp_bin_float<D1, B1, A1, E1, M1, M2>& val)
constexpr std::size_t hash_value(const cpp_bin_float<D1, B1, A1, E1, M1, M2>& val)
{
std::size_t result = hash_value(val.bits());
boost::multiprecision::detail::hash_combine(result, val.exponent(), val.sign());
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/cpp_dec_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,7 @@ inline int eval_signbit(const cpp_dec_float<Digits10, ExponentType, Allocator>&
}

template <unsigned Digits10, class ExponentType, class Allocator>
inline std::size_t hash_value(const cpp_dec_float<Digits10, ExponentType, Allocator>& val)
constexpr std::size_t hash_value(const cpp_dec_float<Digits10, ExponentType, Allocator>& val)
{
return val.hash();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ struct numeric_limits<FloatingPointType,
static constexpr auto epsilon() -> self_type
{
// This double value has only one bit set and so is exact.
return 1.92592994438723585305597794258492732e-34;
// N[2^-112, 84]

return 1.92592994438723585305597794258492731853810164821538819523993879556655883789062500000e-34;
}

static constexpr auto round_error() noexcept -> self_type { return static_cast<self_type>(0.5F); }
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/cpp_int/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ eval_msb(const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocato
}

template <std::size_t MinBits1, std::size_t MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& val) noexcept
constexpr std::size_t hash_value(const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& val) noexcept
{
std::size_t result = 0;
for (std::size_t i = 0; i < val.size(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/debug_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ int eval_signbit(const debug_adaptor<Backend>& val)
}

template <class Backend>
std::size_t hash_value(const debug_adaptor<Backend>& val)
constexpr std::size_t hash_value(const debug_adaptor<Backend>& val)
{
return hash_value(val.value());
}
Expand Down
12 changes: 6 additions & 6 deletions include/boost/multiprecision/detail/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
namespace boost { namespace multiprecision { namespace detail {

template <typename T>
inline std::size_t hash_value(const T& v)
BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const T& v)
{
std::hash<T> hasher;
return hasher(v);
}

#if defined(BOOST_HAS_INT128)

std::size_t hash_value(const uint128_type& val);
constexpr std::size_t hash_value(const uint128_type& val);

inline std::size_t hash_value(const int128_type& val)
constexpr std::size_t hash_value(const int128_type& val)
{
return hash_value(static_cast<uint128_type>(val));
}

#endif

inline void hash_combine(std::size_t&) {}
constexpr void hash_combine(std::size_t&) {}

template <typename T, typename... Args>
inline void hash_combine(std::size_t& seed, const T& v, Args... args)
constexpr void hash_combine(std::size_t& seed, const T& v, Args... args)
{
constexpr std::size_t adder = 0x9e3779b9;
seed = seed ^ (hash_value(v) + adder + (seed<<6) + (seed>>2));
Expand All @@ -42,7 +42,7 @@ inline void hash_combine(std::size_t& seed, const T& v, Args... args)

#if defined(BOOST_HAS_INT128)

inline std::size_t hash_value(const uint128_type& val)
constexpr std::size_t hash_value(const uint128_type& val)
{
std::size_t result = static_cast<std::size_t>(val);
hash_combine(result, static_cast<std::size_t>(val >> 64));
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/float128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ inline int eval_signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const float128_backend&
}
#endif

inline std::size_t hash_value(const float128_backend& val)
constexpr std::size_t hash_value(const float128_backend& val)
{
return boost::multiprecision::detail::hash_value(static_cast<double>(val.value()));
}
Expand Down
6 changes: 3 additions & 3 deletions include/boost/multiprecision/gmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ inline void eval_frexp(gmp_float<Digits10>& result, const gmp_float<Digits10>& v
}

template <unsigned Digits10>
inline std::size_t hash_value(const gmp_float<Digits10>& val)
constexpr std::size_t hash_value(const gmp_float<Digits10>& val)
{
std::size_t result = 0;
for (int i = 0; i < std::abs(val.data()[0]._mp_size); ++i)
Expand Down Expand Up @@ -2353,7 +2353,7 @@ eval_powm(gmp_int& result, const gmp_int& base, Integer p, const gmp_int& m)
mpz_powm_ui(result.data(), base.data(), p, m.data());
}

inline std::size_t hash_value(const gmp_int& val)
constexpr std::size_t hash_value(const gmp_int& val)
{
// We should really use mpz_limbs_read here, but that's unsupported on older versions:
std::size_t result = 0;
Expand Down Expand Up @@ -3131,7 +3131,7 @@ void assign_components(gmp_rational& result, const T& a, const gmp_int& b)
}


inline std::size_t hash_value(const gmp_rational& val)
constexpr std::size_t hash_value(const gmp_rational& val)
{
std::size_t result = 0;
for (int i = 0; i < std::abs(val.data()[0]._mp_num._mp_size); ++i)
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/logged_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ int eval_signbit(const logged_adaptor<Backend>& val)
}

template <class Backend>
std::size_t hash_value(const logged_adaptor<Backend>& val)
constexpr std::size_t hash_value(const logged_adaptor<Backend>& val)
{
return hash_value(val.value());
}
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/mpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ inline void eval_set_imag(mpc_complex_backend<Digits10>& result, const long long
#endif

template <unsigned Digits10>
inline std::size_t hash_value(const mpc_complex_backend<Digits10>& val)
constexpr std::size_t hash_value(const mpc_complex_backend<Digits10>& val)
{
std::size_t result = 0;
std::size_t len = val.data()[0].re[0]._mpfr_prec / mp_bits_per_limb;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/mpfi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ inline void eval_log2(mpfi_float_backend<Digits10>& result, const mpfi_float_bac
}

template <unsigned Digits10>
inline std::size_t hash_value(const mpfi_float_backend<Digits10>& val)
constexpr std::size_t hash_value(const mpfi_float_backend<Digits10>& val)
{
std::size_t result = 0;
std::size_t len = val.left_data()[0]._mpfr_prec / mp_bits_per_limb;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/mpfr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ inline int eval_signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const mpfr_float_backen
}

template <unsigned Digits10, mpfr_allocation_type AllocateType>
inline std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
constexpr std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
{
std::size_t result = 0;
std::size_t len = val.data()[0]._mpfr_prec / mp_bits_per_limb;
Expand Down
8 changes: 4 additions & 4 deletions include/boost/multiprecision/number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2364,7 +2364,7 @@ BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void swap(number<Backend, Expressi
// Boost.Hash support, just call hash_value for the backend, which may or may not be supported:
//
template <class Backend, expression_template_option ExpressionTemplates>
inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const number<Backend, ExpressionTemplates>& val)
constexpr std::size_t hash_value(const number<Backend, ExpressionTemplates>& val)
{
return hash_value(val.backend());
}
Expand Down Expand Up @@ -2443,7 +2443,7 @@ inline BOOST_MP_CXX14_CONSTEXPR multiprecision::number<T, ExpressionTemplates> d
}

template <class T, multiprecision::expression_template_option ExpressionTemplates>
inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const rational<multiprecision::number<T, ExpressionTemplates> >& val)
constexpr std::size_t hash_value(const rational<multiprecision::number<T, ExpressionTemplates> >& val)
{
std::size_t result = hash_value(val.numerator());
boost::multiprecision::detail::hash_combine(result, hash_value(val.denominator()));
Expand Down Expand Up @@ -2471,12 +2471,12 @@ namespace std {
template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
struct hash<boost::multiprecision::number<Backend, ExpressionTemplates> >
{
BOOST_MP_CXX14_CONSTEXPR std::size_t operator()(const boost::multiprecision::number<Backend, ExpressionTemplates>& val) const { return hash_value(val); }
constexpr std::size_t operator()(const boost::multiprecision::number<Backend, ExpressionTemplates>& val) const { return hash_value(val); }
};
template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
struct hash<boost::rational<boost::multiprecision::number<Backend, ExpressionTemplates> > >
{
BOOST_MP_CXX14_CONSTEXPR std::size_t operator()(const boost::rational<boost::multiprecision::number<Backend, ExpressionTemplates> >& val) const
constexpr std::size_t operator()(const boost::rational<boost::multiprecision::number<Backend, ExpressionTemplates> >& val) const
{
std::size_t result = hash_value(val.numerator());
boost::multiprecision::detail::hash_combine(result, hash_value(val.denominator()));
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/rational_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ inline typename std::enable_if<number_category<R>::value == number_kind_integer>
// Hashing support, not strictly required, but it is used in our tests:
//
template <class Backend>
inline std::size_t hash_value(const rational_adaptor<Backend>& arg)
constexpr std::size_t hash_value(const rational_adaptor<Backend>& arg)
{
std::size_t result = hash_value(arg.num());
std::size_t result2 = hash_value(arg.denom());
Expand Down
2 changes: 1 addition & 1 deletion include/boost/multiprecision/tommath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ inline typename std::enable_if<boost::multiprecision::detail::is_signed<Integer>
return eval_integer_modulus(x, boost::multiprecision::detail::unsigned_abs(val));
}

inline std::size_t hash_value(const tommath_int& val)
constexpr std::size_t hash_value(const tommath_int& val)
{
std::size_t result = 0;
std::size_t len = val.data().used;
Expand Down
Loading