summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--gmpxx.h114
2 files changed, 118 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d1abec62d..c1b7ca556 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-02-29 Marc Glisse <marc.glisse@inria.fr>
+
+ * gmpxx.h (std::numeric_limits): New partial specialization.
+
2012-02-29 Niels Möller <nisse@lysator.liu.se>
* mini-gmp/tests/t-reuse.c: New test case, based on
diff --git a/gmpxx.h b/gmpxx.h
index eac829385..3a0684036 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -24,6 +24,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include <iosfwd>
#include <cstring> /* for strlen */
+#include <limits> /* numeric_limits */
#include <utility>
#include <string>
#include <stdexcept>
@@ -3228,6 +3229,119 @@ public:
};
+/**************** Specialize std::numeric_limits ****************/
+
+namespace std {
+ template <> class numeric_limits<mpz_class>
+ {
+ static const bool is_specialized = true;
+ static mpz_class min() { return mpz_class(); }
+ static mpz_class max() { return mpz_class(); }
+ static mpz_class lowest() { return mpz_class(); }
+ static const int digits = 0;
+ static const int digits10 = 0;
+ static const int max_digits10 = 0;
+ static const bool is_signed = true;
+ static const bool is_integer = true;
+ static const bool is_exact = true;
+ static const int radix = 2;
+ static mpz_class epsilon() { return mpz_class(); }
+ static mpz_class round_error() { return mpz_class(); }
+ static const int min_exponent = 0;
+ static const int min_exponent10 = 0;
+ static const int max_exponent = 0;
+ static const int max_exponent10 = 0;
+ static const bool has_infinity = false;
+ static const bool has_quiet_NaN = false;
+ static const bool has_signaling_NaN = false;
+ static const float_denorm_style has_denorm = denorm_absent;
+ static const bool has_denorm_loss = false;
+ static mpz_class infinity() { return mpz_class(); }
+ static mpz_class quiet_NaN() { return mpz_class(); }
+ static mpz_class signaling_NaN() { return mpz_class(); }
+ static mpz_class denorm_min() { return mpz_class(); }
+ static const bool is_iec559 = false;
+ static const bool is_bounded = false;
+ static const bool is_modulo = false;
+ static const bool traps = false;
+ static const bool tinyness_before = false;
+ static const float_round_style round_style = round_toward_zero;
+ };
+
+ template <> class numeric_limits<mpq_class>
+ {
+ static const bool is_specialized = true;
+ static mpq_class min() { return mpq_class(); }
+ static mpq_class max() { return mpq_class(); }
+ static mpq_class lowest() { return mpq_class(); }
+ static const int digits = 0;
+ static const int digits10 = 0;
+ static const int max_digits10 = 0;
+ static const bool is_signed = true;
+ static const bool is_integer = false;
+ static const bool is_exact = true;
+ static const int radix = 2;
+ static mpq_class epsilon() { return mpq_class(); }
+ static mpq_class round_error() { return mpq_class(); }
+ static const int min_exponent = 0;
+ static const int min_exponent10 = 0;
+ static const int max_exponent = 0;
+ static const int max_exponent10 = 0;
+ static const bool has_infinity = false;
+ static const bool has_quiet_NaN = false;
+ static const bool has_signaling_NaN = false;
+ static const float_denorm_style has_denorm = denorm_absent;
+ static const bool has_denorm_loss = false;
+ static mpq_class infinity() { return mpq_class(); }
+ static mpq_class quiet_NaN() { return mpq_class(); }
+ static mpq_class signaling_NaN() { return mpq_class(); }
+ static mpq_class denorm_min() { return mpq_class(); }
+ static const bool is_iec559 = false;
+ static const bool is_bounded = false;
+ static const bool is_modulo = false;
+ static const bool traps = false;
+ static const bool tinyness_before = false;
+ static const float_round_style round_style = round_toward_zero;
+ };
+
+ template <> class numeric_limits<mpf_class>
+ {
+ static const bool is_specialized = true;
+ static mpf_class min() { return mpf_class(); }
+ static mpf_class max() { return mpf_class(); }
+ static mpf_class lowest() { return mpf_class(); }
+ static const int digits = 0;
+ static const int digits10 = 0;
+ static const int max_digits10 = 0;
+ static const bool is_signed = true;
+ static const bool is_integer = false;
+ static const bool is_exact = false;
+ static const int radix = 2;
+ static mpf_class epsilon() { return mpf_class(); }
+ static mpf_class round_error() { return mpf_class(); }
+ static const int min_exponent = 0;
+ static const int min_exponent10 = 0;
+ static const int max_exponent = 0;
+ static const int max_exponent10 = 0;
+ static const bool has_infinity = false;
+ static const bool has_quiet_NaN = false;
+ static const bool has_signaling_NaN = false;
+ static const float_denorm_style has_denorm = denorm_absent;
+ static const bool has_denorm_loss = false;
+ static mpf_class infinity() { return mpf_class(); }
+ static mpf_class quiet_NaN() { return mpf_class(); }
+ static mpf_class signaling_NaN() { return mpf_class(); }
+ static mpf_class denorm_min() { return mpf_class(); }
+ static const bool is_iec559 = false;
+ static const bool is_bounded = false;
+ static const bool is_modulo = false;
+ static const bool traps = false;
+ static const bool tinyness_before = false;
+ static const float_round_style round_style = round_indeterminate;
+ };
+}
+
+
/**************** #undef all private macros ****************/
#undef __GMPP_DECLARE_COMPOUND_OPERATOR