From 0055f045edecee98b8f90a0341a1ec2f01d0f1b5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 27 Dec 2014 18:17:58 +0100 Subject: Prepare for expressions like factorial(int). --- gmpxx.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'gmpxx.h') 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 struct __gmp_unary_expr { - const T &val; + typename __gmp_resolve_ref::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 __gmp_expr > +{ +private: + typedef U val_type; + + __gmp_unary_expr expr; +public: + explicit __gmp_expr(const val_type &val) : expr(val) { } + void eval(typename __gmp_resolve_expr::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 @@ -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 __gmp_expr, U, Op> > -- cgit v1.2.1