add std::ostream &operator<<(std::ostream &os, isl_int i) (for C++ builds)
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 9 Jan 2009 11:43:30 +0000 (12:43 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 9 Jan 2009 11:43:30 +0000 (12:43 +0100)
include/isl_int.h

index ddb2422..274aee9 100644 (file)
@@ -4,6 +4,9 @@
 #include <isl_hash.h>
 #include <string.h>
 #include <gmp.h>
+#if defined(__cplusplus)
+#include <iostream>
+#endif
 
 #if defined(__cplusplus)
 extern "C" {
@@ -88,4 +91,17 @@ uint32_t isl_gmp_hash(mpz_t v, uint32_t hash);
 }
 #endif
 
+#if defined(__cplusplus)
+static inline std::ostream &operator<<(std::ostream &os, isl_int i)
+{
+       char *s;
+       void (*gmp_free)(void *, size_t);
+       s = mpz_get_str(0, 10, i);
+       os << s;
+       mp_get_memory_functions(NULL, NULL, &gmp_free);
+       (*gmp_free)(s, strlen(s)+1);
+       return os;
+}
+#endif
+
 #endif