From 6a32f7e4445372fe97c4b6a2415b90dba2deb6db Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 18 Jan 2019 18:01:33 +0000 Subject: Remove boost_multiprecision_number_compare_bug_workaround for Boost <=1.58 --- libdevcore/CMakeLists.txt | 1 - libdevcore/Common.h | 18 - ...ultiprecision_number_compare_bug_workaround.hpp | 520 --------------------- 3 files changed, 539 deletions(-) delete mode 100644 libdevcore/boost_multiprecision_number_compare_bug_workaround.hpp diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt index e68ac10a..193fa41d 100644 --- a/libdevcore/CMakeLists.txt +++ b/libdevcore/CMakeLists.txt @@ -1,7 +1,6 @@ set(sources Algorithms.h Assertions.h - boost_multiprecision_number_compare_bug_workaround.hpp Common.h CommonData.cpp CommonData.h diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 6208424e..08757daf 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -39,26 +39,8 @@ #include -#if defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif // defined(__GNUC__) - -// See https://github.com/ethereum/libweb3core/commit/90680a8c25bfb48b24371b4abcacde56c181517c -// See https://svn.boost.org/trac/boost/ticket/11328 -// Bob comment - perhaps we should just HARD FAIL here with Boost-1.58.00? -// It is quite old now, and requiring end-users to use a newer Boost release is probably not unreasonable. -#include -#if (BOOST_VERSION == 105800) - #include "boost_multiprecision_number_compare_bug_workaround.hpp" -#endif // (BOOST_VERSION == 105800) - #include -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif // defined(__GNUC__) - #include #include #include diff --git a/libdevcore/boost_multiprecision_number_compare_bug_workaround.hpp b/libdevcore/boost_multiprecision_number_compare_bug_workaround.hpp deleted file mode 100644 index 2568e17d..00000000 --- a/libdevcore/boost_multiprecision_number_compare_bug_workaround.hpp +++ /dev/null @@ -1,520 +0,0 @@ - -// This is a copy of boost/multiprecision/detail/number_compare.hpp from boost 1.59 to replace buggy version from 1.58. - -#ifdef BOOST_MP_COMPARE_HPP -#error This bug workaround header must be included before original boost/multiprecision/detail/number_compare.hpp -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Copyright 2012 John Maddock. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MP_COMPARE_HPP -#define BOOST_MP_COMPARE_HPP - -// A copy of boost/multiprecision/traits/is_backend.hpp -#ifndef BOOST_MP_IS_BACKEND_HPP -#define BOOST_MP_IS_BACKEND_HPP - -#include -#include -#include -#include -#include - -namespace boost{ namespace multiprecision{ namespace detail{ - - BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types) - BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types) - BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types) - - template - struct is_backend - { - static const bool value = has_signed_types::value && has_unsigned_types::value && has_float_types::value; - }; - - template - struct other_backend - { - typedef typename boost::conditional< - boost::is_same, number >::value, - number, number >::type type; - }; - - template - struct number_from_backend - { - typedef typename boost::conditional < - boost::is_convertible >::value, - number, - typename other_backend::type > ::type type; - }; - - template - struct is_first_backend_imp{ static const bool value = false; }; - template - struct is_first_backend_imp{ static const bool value = is_convertible >::value || is_convertible >::value; }; - - template - struct is_first_backend : is_first_backend_imp::value, T, U> {}; - - template - struct is_second_backend_imp{ static const bool value = false; }; - template - struct is_second_backend_imp{ static const bool value = is_convertible >::value || is_convertible >::value; }; - - template - struct is_second_backend : is_second_backend_imp::value, T, U> {}; - -} -} -} - -#endif // BOOST_MP_IS_BACKEND_HPP - -// -// Comparison operators for number. -// - -namespace boost{ namespace multiprecision{ - -namespace default_ops{ - -template -inline bool eval_eq(const B& a, const B& b) -{ - return a.compare(b) == 0; -} -template -inline typename enable_if_c::value, bool>::type eval_eq(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(b); - return eval_eq(a, t.backend()); -} -template -inline typename enable_if_c::value, bool>::type eval_eq(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(a); - return eval_eq(t.backend(), b); -} - -template -inline bool eval_lt(const B& a, const B& b) -{ - return a.compare(b) < 0; -} -template -inline typename enable_if_c::value, bool>::type eval_lt(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(b); - return eval_lt(a, t.backend()); -} -template -inline typename enable_if_c::value, bool>::type eval_lt(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(a); - return eval_lt(t.backend(), b); -} - -template -inline bool eval_gt(const B& a, const B& b) -{ - return a.compare(b) > 0; -} -template -inline typename enable_if_c::value, bool>::type eval_gt(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(b); - return eval_gt(a, t.backend()); -} -template -inline typename enable_if_c::value, bool>::type eval_gt(const T& a, const U& b) -{ - typename boost::multiprecision::detail::number_from_backend::type t(a); - return eval_gt(t.backend(), b); -} - -} // namespace default_ops - -namespace detail{ - -template -struct is_valid_mixed_compare : public mpl::false_ {}; - -template -struct is_valid_mixed_compare, Val> : public is_convertible > {}; - -template -struct is_valid_mixed_compare, number > : public mpl::false_ {}; - -template -struct is_valid_mixed_compare, expression > - : public mpl::bool_, number >::value> {}; - -template -struct is_valid_mixed_compare, number > - : public mpl::bool_, number >::value> {}; - -template -inline BOOST_CONSTEXPR typename boost::enable_if_c::value != number_kind_floating_point, bool>::type is_unordered_value(const number&) -{ - return false; -} -template -inline BOOST_CONSTEXPR typename boost::enable_if_c::value == number_kind_floating_point, bool>::type is_unordered_value(const number& a) -{ - using default_ops::eval_fpclassify; - return eval_fpclassify(a.backend()) == FP_NAN; -} - -template -inline BOOST_CONSTEXPR typename boost::enable_if_c::value != number_kind_floating_point, bool>::type is_unordered_value(const Arithmetic&) -{ - return false; -} -template -inline BOOST_CONSTEXPR typename boost::enable_if_c::value == number_kind_floating_point, bool>::type is_unordered_value(const Arithmetic& a) -{ - return (boost::math::isnan)(a); -} - -template -inline BOOST_CONSTEXPR bool is_unordered_comparison(const T& a, const U& b) -{ - return is_unordered_value(a) || is_unordered_value(b); -} - -} - -template -inline bool operator == (const number& a, const number& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_eq(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator == (const number& a, const Arithmetic& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_eq(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator == (const Arithmetic& a, const number& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_eq(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator == (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_eq; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return false; - return eval_eq(t.backend(), result_type::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator == (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_eq; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return false; - return eval_eq(t.backend(), result_type::canonical_value(b)); -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator == (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_eq; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return false; - return eval_eq(t.backend(), t2.backend()); -} - -template -inline bool operator != (const number& a, const number& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return true; - return !eval_eq(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator != (const number& a, const Arithmetic& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return true; - return !eval_eq(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator != (const Arithmetic& a, const number& b) -{ - using default_ops::eval_eq; - if(detail::is_unordered_comparison(a, b)) return true; - return !eval_eq(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator != (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_eq; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return true; - return !eval_eq(t.backend(), result_type::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator != (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_eq; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return true; - return !eval_eq(t.backend(), result_type::canonical_value(b)); -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator != (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_eq; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return true; - return !eval_eq(t.backend(), t2.backend()); -} - -template -inline bool operator < (const number& a, const number& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_lt(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator < (const number& a, const Arithmetic& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_lt(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator < (const Arithmetic& a, const number& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_gt(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator < (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_gt; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return false; - return eval_gt(t.backend(), result_type::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator < (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_lt; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return false; - return eval_lt(t.backend(), result_type::canonical_value(b)); -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator < (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_lt; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return false; - return eval_lt(t.backend(), t2.backend()); -} - -template -inline bool operator > (const number& a, const number& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_gt(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator > (const number& a, const Arithmetic& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_gt(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator > (const Arithmetic& a, const number& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return eval_lt(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator > (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_lt; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return false; - return a > t; -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator > (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_gt; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return false; - return t > b; -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator > (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_gt; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return false; - return t > t2; -} - -template -inline bool operator <= (const number& a, const number& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_gt(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator <= (const number& a, const Arithmetic& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_gt(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator <= (const Arithmetic& a, const number& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_lt(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator <= (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_lt; - if(detail::is_unordered_value(a) || detail::is_unordered_value(b)) - return false; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return false; - return !eval_lt(t.backend(), result_type::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator <= (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_gt; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return false; - return !eval_gt(t.backend(), result_type::canonical_value(b)); -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator <= (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_gt; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return false; - return !eval_gt(t.backend(), t2.backend()); -} - -template -inline bool operator >= (const number& a, const number& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_lt(a.backend(), b.backend()); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator >= (const number& a, const Arithmetic& b) -{ - using default_ops::eval_lt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_lt(a.backend(), number::canonical_value(b)); -} -template -inline typename enable_if_c, Arithmetic>::value, bool>::type - operator >= (const Arithmetic& a, const number& b) -{ - using default_ops::eval_gt; - if(detail::is_unordered_comparison(a, b)) return false; - return !eval_gt(b.backend(), number::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator >= (const Arithmetic& a, const detail::expression& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_gt; - result_type t(b); - if(detail::is_unordered_comparison(a, t)) return false; - return !eval_gt(t.backend(), result_type::canonical_value(a)); -} -template -inline typename enable_if_c::result_type, Arithmetic>::value, bool>::type - operator >= (const detail::expression& a, const Arithmetic& b) -{ - typedef typename detail::expression::result_type result_type; - using default_ops::eval_lt; - result_type t(a); - if(detail::is_unordered_comparison(t, b)) return false; - return !eval_lt(t.backend(), result_type::canonical_value(b)); -} -template -inline typename enable_if::result_type, typename detail::expression::result_type>, bool>::type - operator >= (const detail::expression& a, const detail::expression& b) -{ - using default_ops::eval_lt; - typename detail::expression::result_type t(a); - typename detail::expression::result_type t2(b); - if(detail::is_unordered_comparison(t, t2)) return false; - return !eval_lt(t.backend(), t2.backend()); -} - - -}} // namespaces - -#endif // BOOST_MP_COMPARE_HPP -- cgit