--- src/tools/ParseExp.cpp	2013-10-27 10:19:02.000000000 +0100
+++ src/tools/ParseExp.cpp	2014-09-12 01:41:15.468973470 +0200
@@ -50,37 +50,45 @@
 //power function
 struct lazy_pow_
 {
-    template <typename X, typename Y>
-    struct result { typedef X type; };
+    template<class> struct result;
+
+    template <typename F, typename X, typename Y>
+    struct result<F(X,Y)> { typedef X& type; };
 
     template <typename X, typename Y>
-    X operator()(X x, Y y) const
+    X& operator()(X& x, Y y) const
     {
-        return std::pow(x, y);
+        x= std::pow(x, y);
+        return x;
     }
 };
 
 // modulus for double values
 struct lazy_mod_
 {
-    template <typename X, typename Y>
-    struct result { typedef X type; };
+    template<class> struct result;
+
+    template <typename F, typename X, typename Y>
+    struct result<F(X,Y)> { typedef X& type; };
 
     template <typename X, typename Y>
-    X operator()(X x, Y y) const
+    X& operator()(X& x, Y y) const
     {
-        return std::fmod(x,y);
+        x= std::fmod(x,y);
+        return x;
     }
 };
 
 // if statement
 struct lazy_if_
 {
-    template <typename X, typename Y, typename Z>
-    struct result { typedef Y type; };
+    template<class> struct result;
 
-    template <typename X, typename Y, typename Z>
-    X operator()(X x, Y y, Z z) const
+    template <typename F, typename X, typename Y>
+    struct result<F(X,Y,Y)> { typedef Y& type; };
+
+    template <typename X, typename Y>
+    Y& operator()(X x, Y& y, Y& z) const
     {
         return x ? y : z;
     }
@@ -89,13 +97,16 @@
 // wrapper for unary function
 struct lazy_ufunc_
 {
-    template <typename F, typename A1>
-    struct result { typedef A1 type; };
+    template<class> struct result;
+
+    template<typename F, typename F1, typename A1>
+    struct result<F(F1,A1)> { typedef A1& type; };
 
     template <typename F, typename A1>
-    A1 operator()(F f, A1 a1) const
+    A1& operator()(F f, A1& a1) const
     {
-        return f(a1);
+        a1= f(a1);
+        return a1;
     }
 };
 
