summaryrefslogtreecommitdiff
path: root/gmpxx.h
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2014-12-27 18:17:58 +0100
committerMarc Glisse <marc.glisse@inria.fr>2014-12-27 18:17:58 +0100
commit0055f045edecee98b8f90a0341a1ec2f01d0f1b5 (patch)
treea90a15e7901bf7c5b9fb917b9ef50d0170808b2d /gmpxx.h
parenta3f68dc69d78dd92484b209c5c5a84b447c54aeb (diff)
downloadgmp-0055f045edecee98b8f90a0341a1ec2f01d0f1b5.tar.gz
Prepare for expressions like factorial(int).
Diffstat (limited to 'gmpxx.h')
-rw-r--r--gmpxx.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/gmpxx.h b/gmpxx.h
index acb7c4161..04256947f 100644
--- a/gmpxx.h
+++ b/gmpxx.h
@@ -1304,7 +1304,7 @@ namespace std {
template <class T, class Op>
struct __gmp_unary_expr
{
- const T &val;
+ typename __gmp_resolve_ref<T>::ref_type val;
__gmp_unary_expr(const T &v) : val(v) { }
private:
@@ -2148,6 +2148,24 @@ public:
};
+// simple expressions, U is a built-in numerical type
+
+template <class T, class U, class Op>
+class __gmp_expr<T, __gmp_unary_expr<U, Op> >
+{
+private:
+ typedef U val_type;
+
+ __gmp_unary_expr<val_type, Op> expr;
+public:
+ explicit __gmp_expr(const val_type &val) : expr(val) { }
+ void eval(typename __gmp_resolve_expr<T>::ptr_type p) const
+ { Op::eval(p, expr.val); }
+ const val_type & get_val() const { return expr.val; }
+ mp_bitcnt_t get_prec() const { return mpf_get_default_prec(); }
+};
+
+
// compound expressions
template <class T, class U, class Op>
@@ -2203,7 +2221,7 @@ public:
};
-// simple expressions, T is a built-in numerical type
+// simple expressions, U is a built-in numerical type
template <class T, class U, class Op>
class __gmp_expr<T, __gmp_binary_expr<__gmp_expr<T, T>, U, Op> >