[Gmp-commit] /var/hg/gmp: Add constructor mpq_class(mpz_class&&)

mercurial at gmplib.org mercurial at gmplib.org
Sun Jun 20 13:21:42 UTC 2021


details:   /var/hg/gmp/rev/1694ca7a775e
changeset: 18226:1694ca7a775e
user:      Marc Glisse <marc.glisse at inria.fr>
date:      Sun Jun 20 15:21:23 2021 +0200
description:
Add constructor mpq_class(mpz_class&&)
Surprisingly, the corresponding test was already present.

diffstat:

 ChangeLog |  4 ++++
 gmpxx.h   |  6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r 143e9a7f3ece -r 1694ca7a775e ChangeLog
--- a/ChangeLog	Sun Jun 20 14:21:52 2021 +0200
+++ b/ChangeLog	Sun Jun 20 15:21:23 2021 +0200
@@ -1,3 +1,7 @@
+2021-06-20  Marc Glisse  <marc.glisse at inria.fr>
+
+	* gmpxx.h (mpq_class(mpz_class&&)): New constructor.
+
 2021-06-20  Niels Möller  <nisse at lysator.liu.se>
 
 	* doc/gmp.texi: Document foo_ptr and foo_srcptr.
diff -r 143e9a7f3ece -r 1694ca7a775e gmpxx.h
--- a/gmpxx.h	Sun Jun 20 14:21:52 2021 +0200
+++ b/gmpxx.h	Sun Jun 20 15:21:23 2021 +0200
@@ -1795,6 +1795,12 @@
 #if __GMPXX_USE_CXX11
   __gmp_expr(__gmp_expr &&q)
   { *mp = *q.mp; mpq_init(q.mp); }
+  __gmp_expr(mpz_class &&z)
+  {
+    *mpq_numref(mp) = *z.get_mpz_t();
+    mpz_init_set_ui(mpq_denref(mp), 1);
+    mpz_init(z.get_mpz_t());
+  }
 #endif
   template <class T>
   __gmp_expr(const __gmp_expr<mpz_t, T> &expr)


More information about the gmp-commit mailing list