summaryrefslogtreecommitdiff
path: root/gmpxx.h
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2012-03-08 22:34:36 +0100
committerMarc Glisse <marc.glisse@inria.fr>2012-03-08 22:34:36 +0100
commite4d2b95ced513bc58a510f151e42a087629ccedd (patch)
tree0976728a727aa474c1d7d2ac97a36ff9adbec1c5 /gmpxx.h
parent9d7d6e431e2a9b3d573c3f0ac1d20bc2826d2ad2 (diff)
downloadgmp-e4d2b95ced513bc58a510f151e42a087629ccedd.tar.gz
C++11 user-defined literals
Diffstat (limited to 'gmpxx.h')
-rw-r--r--gmpxx.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/gmpxx.h b/gmpxx.h
index 3a0684036..a218166d7 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -40,8 +40,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
// Use C++11 features
#ifndef __GMPXX_USE_CXX11
-#if (__cplusplus >= 201103L) \
- || (__GMP_GNUC_PREREQ(4, 6) && defined __GXX_EXPERIMENTAL_CXX0X__)
+#if __cplusplus >= 201103L
#define __GMPXX_USE_CXX11 1
#else
#define __GMPXX_USE_CXX11 0
@@ -1981,6 +1980,27 @@ typedef __gmp_expr<mpf_t, mpf_t> mpf_class;
+/**************** User-defined literals ****************/
+
+#if __GMPXX_USE_CXX11
+inline mpz_class operator"" _mpz(const char* s)
+{
+ return mpz_class(s);
+}
+
+inline mpq_class operator"" _mpq(const char* s)
+{
+ mpq_class q;
+ q.get_num() = s;
+ return q;
+}
+
+inline mpf_class operator"" _mpf(const char* s)
+{
+ return mpf_class(s);
+}
+#endif
+
/**************** I/O operators ****************/
// these should (and will) be provided separately