diff --git a/exprtk.hpp b/exprtk.hpp index afb9add..30d8b7d 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -955,14 +955,14 @@ namespace exprtk } } - template + template inline T process(const operator_type operation, const T& arg) { typename details::number_type::type num_type; return details::process_impl(operation,arg,num_type); } - template + template inline T process(const operator_type operation, const T& arg0, const T& arg1) { typename details::number_type::type num_type; @@ -1008,7 +1008,7 @@ namespace exprtk } }; - template + template inline bool branch_deletable(expression_node* expr) { return expression_node::e_variable != expr->type(); @@ -1656,8 +1656,7 @@ namespace exprtk cleanup_branches(branch_); } - - template + template void init_branches(expression_ptr (&b)[NumBranches]) { for (std::size_t i = 0; i < NumBranches; ++i) @@ -1951,7 +1950,7 @@ namespace exprtk } // namespace details - template + template class ifunction { public: @@ -2324,8 +2323,8 @@ namespace exprtk add_variable("inf",infinity,true); } - template class Sequence> + template class Sequence> inline std::size_t get_variable_list(Sequence,Allocator>& vlist) { std::size_t count = 0; @@ -2788,6 +2787,7 @@ namespace exprtk ptr_t* p_; private: + scoped_delete& operator=(const scoped_delete&); }; @@ -3253,7 +3253,7 @@ namespace exprtk return synthesize_expression(operation,branch); } - template + template inline expression_node_ptr function(typename function_node_t::ifunction* f, expression_node_ptr (&b)[N]) { expression_node_ptr result = synthesize_expression(f,b); diff --git a/exprtk_test.cpp b/exprtk_test.cpp index a933c20..6693416 100644 --- a/exprtk_test.cpp +++ b/exprtk_test.cpp @@ -784,6 +784,7 @@ inline bool run_test1() std::cout << "run_test1() - Error: " << parser.error() << "\tExpression: " << expression_string << std::endl; return false; } + expression.value(); return true; } @@ -997,6 +998,22 @@ inline bool run_test6() "x", "y", "z", "w", "u", "x + y + z + w + u", "x + y / z * w ^ u", + "x:=1.1", "y:=2.2", "z:=3.3", "w:=4.4", "u:=5.5", + "x<-1.1", "y<-2.2", "z<-3.3", "w<-4.4", "u<-5.5", + "x:=x+1.1", "y:=y+2.2", "z:=z+3.3", "w:=w+4.4", "u:=u+5.5", + "x<-x+1.1", "y<-y+2.2", "z<-z+3.3", "w<-w+4.4", "u<-u+5.5", + "x:=1.1+x", "y:=2.2+y", "z:=3.3+z", "w:=4.4+w", "u:=5.5+u", + "x<-1.1+x", "y<-2.2+y", "z<-3.3+z", "w<-4.4+w", "u<-5.5+u", + "x:=(x <= 1.1)", + "y:=(2.2 >= y)", + "z:=(3.3 and z)", + "w:=(4.4 or w)", + "u:=(u xor 5.5)", + "x<-(x <= 1.1)", + "y<-(2.2 >= y)", + "z<-(3.3 and z)", + "w<-(4.4 or w)", + "u<-(u xor 5.5)", "min(x,y) + min(x,y,z) + min(x,y,z,w) + min(x,y,z,w,y)", "max(x,y) + max(x,y,z) + max(x,y,z,w) + max(x,y,z,w,y)", "avg(x,y)", @@ -1144,12 +1161,24 @@ inline bool run_test7() std::cout << "run_test7() - Error: " << parser.error() << "\tExpression: " << expression_string << std::endl; return false; } - T result = expression.value(); const T pi = T(3.14159265358979323846); - if (not_equal(result,(T(1)+(std::sin(x*pi)*(y/T(2)))/T(3)) * 10.0,0.000001)) + + T result = expression.value(); + T expected = mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2) + + mf(sin(x*pi),y/2); + + if (not_equal(result,expected,0.0000001)) { printf("run_test7() - Error Expected: %19.15f\tResult: %19.15f\n", - T(1)+(std::sin(x*pi)*(y/T(2)))/T(3), + expected, result); return false; } @@ -1170,4 +1199,4 @@ int main() run_test7() ) ? 0 : 1; - } +}