From 17ba4d15e2f78f62d90a20358d85d38ec644ea7b Mon Sep 17 00:00:00 2001 From: Arash Partow Date: Fri, 1 Jan 2021 00:00:00 +0000 Subject: [PATCH] C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html --- .circleci/config.yml | 3 + Makefile | 2 +- exprtk.hpp | 6691 +++++++++++++++++++--------------- exprtk_benchmark.cpp | 14 +- exprtk_functional_test.txt | 212 +- exprtk_simple_example_01.cpp | 6 +- exprtk_simple_example_02.cpp | 6 +- exprtk_simple_example_03.cpp | 6 +- exprtk_simple_example_04.cpp | 12 +- exprtk_simple_example_05.cpp | 6 +- exprtk_simple_example_06.cpp | 6 +- exprtk_simple_example_07.cpp | 6 +- exprtk_simple_example_08.cpp | 16 +- exprtk_simple_example_09.cpp | 12 +- exprtk_simple_example_10.cpp | 12 +- exprtk_simple_example_11.cpp | 6 +- exprtk_simple_example_12.cpp | 6 +- exprtk_simple_example_13.cpp | 12 +- exprtk_simple_example_14.cpp | 4 +- exprtk_simple_example_15.cpp | 10 +- exprtk_simple_example_16.cpp | 24 +- exprtk_simple_example_17.cpp | 6 +- exprtk_simple_example_18.cpp | 6 +- exprtk_simple_example_19.cpp | 12 +- exprtk_test.cpp | 601 ++- readme.txt | 78 +- 26 files changed, 4516 insertions(+), 3259 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e95be7..a0cba13 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,7 @@ jobs: - image: gcc:6 steps: - checkout + - run: c++ --version - run: make all -j 2 - run: ./exprtk_test @@ -14,6 +15,7 @@ jobs: - image: gcc:7 steps: - checkout + - run: c++ --version - run: make all -j 2 - run: ./exprtk_test @@ -22,6 +24,7 @@ jobs: - image: gcc:latest steps: - checkout + - run: c++ --version - run: make all -j 2 - run: ./exprtk_test diff --git a/Makefile b/Makefile index 76d43a0..bdae9b1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # ************************************************************** # * C++ Mathematical Expression Toolkit Library * # * * -# * Author: Arash Partow (1999-2020) * +# * Author: Arash Partow (1999-2021) * # * URL: http://www.partow.net/programming/exprtk/index.html * # * * # * Copyright notice: * diff --git a/exprtk.hpp b/exprtk.hpp index 0b2081e..16a4839 100644 --- a/exprtk.hpp +++ b/exprtk.hpp @@ -2,14 +2,14 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2020) * - * URL: http://www.partow.net/programming/exprtk/index.html * + * Author: Arash Partow (1999-2021) * + * URL: https://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * * Free use of the C++ Mathematical Expression Toolkit Library is * * permitted under the guidelines and in accordance with the most * * current version of the MIT License. * - * http://www.opensource.org/licenses/MIT * + * https://www.opensource.org/licenses/MIT * * * * Example expressions: * * (00) (y + x / y) * (x - y / x) * @@ -82,16 +82,26 @@ namespace exprtk #define exprtk_disable_fallthrough_end (void)0; #endif + #if __cplusplus >= 201103L + #define exprtk_override override + #define exprtk_final final + #define exprtk_delete = delete + #else + #define exprtk_override + #define exprtk_final + #define exprtk_delete + #endif + namespace details { - typedef unsigned char uchar_t; - typedef char char_t; - typedef uchar_t* uchar_ptr; - typedef char_t* char_ptr; - typedef uchar_t const* uchar_cptr; + typedef char char_t; + typedef char_t* char_ptr; typedef char_t const* char_cptr; + typedef unsigned char uchar_t; + typedef uchar_t* uchar_ptr; + typedef uchar_t const* uchar_cptr; typedef unsigned long long int _uint64_t; - typedef long long int _int64_t; + typedef long long int _int64_t; inline bool is_whitespace(const char_t c) { @@ -167,7 +177,7 @@ namespace exprtk inline bool is_valid_string_char(const char_t c) { - return std::isprint(static_cast(c)) || + return std::isprint(static_cast(c)) || is_whitespace(c); } @@ -211,8 +221,8 @@ namespace exprtk for (std::size_t i = 0; i < length; ++i) { - const char_t c1 = static_cast(std::tolower(s1[i])); - const char_t c2 = static_cast(std::tolower(s2[i])); + const char_t c1 = static_cast(std::tolower(s1[i])); + const char_t c2 = static_cast(std::tolower(s2[i])); if (c1 > c2) return false; @@ -274,25 +284,21 @@ namespace exprtk std::string result; - if (i < 0) - { - for ( ; i; i /= 10) - { - result += '0' + char(-(i % 10)); - } + const int sign = (i < 0) ? -1 : 1; - result += '-'; - } - else + for ( ; i; i /= 10) { - for ( ; i; i /= 10) - { - result += '0' + char(i % 10); - } + result += '0' + static_cast(sign * (i % 10)); + } + + if (sign < 0) + { + result += '-'; } std::reverse(result.begin(), result.end()); + return result; } @@ -301,7 +307,7 @@ namespace exprtk return to_str(static_cast(i)); } - inline bool is_hex_digit(const std::string::value_type digit) + inline bool is_hex_digit(const uchar_t digit) { return (('0' <= digit) && (digit <= '9')) || (('A' <= digit) && (digit <= 'F')) || @@ -313,12 +319,12 @@ namespace exprtk if (('0' <= h) && (h <= '9')) return (h - '0'); else - return static_cast(std::toupper(h) - 'A'); + return static_cast(std::toupper(h) - 'A'); } template inline bool parse_hex(Iterator& itr, Iterator end, - std::string::value_type& result) + char_t& result) { if ( (end == (itr )) || @@ -597,68 +603,63 @@ namespace exprtk const Iterator data_begin , const Iterator data_end , const typename std::iterator_traits::value_type& zero_or_more, - const typename std::iterator_traits::value_type& zero_or_one ) + const typename std::iterator_traits::value_type& exactly_one ) { const Iterator null_itr(0); - Iterator d_itr = data_begin; - Iterator p_itr = pattern_begin; - Iterator tb_p_itr = null_itr; - Iterator tb_d_itr = null_itr; + Iterator p_itr = pattern_begin; + Iterator d_itr = data_begin; + Iterator np_itr = null_itr; + Iterator nd_itr = null_itr; - while (d_itr != data_end) + for ( ; ; ) { - if (zero_or_more == *p_itr) + const bool pvalid = p_itr != pattern_end; + const bool dvalid = d_itr != data_end; + + if (!pvalid && !dvalid) + break; + + if (pvalid) { - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; - } - - if (pattern_end == p_itr) - return true; - const typename std::iterator_traits::value_type c = *(p_itr); - while ((data_end != d_itr) && !Compare::cmp(c,*d_itr)) + if (zero_or_more == c) { - ++d_itr; + np_itr = p_itr; + nd_itr = d_itr + 1; + ++p_itr; + continue; + } + else if (dvalid && ((exactly_one == c) || Compare::cmp(c,*(d_itr)))) + { + ++p_itr; + ++d_itr; + continue; } - - tb_p_itr = p_itr; - tb_d_itr = d_itr; - - continue; } - else if (!Compare::cmp(*p_itr, *d_itr) && (zero_or_one != *p_itr)) + + if ((null_itr != nd_itr) && (nd_itr <= data_end)) { - if (null_itr == tb_d_itr) - return false; - - d_itr = tb_d_itr++; - p_itr = tb_p_itr; - + p_itr = np_itr; + d_itr = nd_itr; continue; } - ++p_itr; - ++d_itr; + return false; } - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; - } - - return (pattern_end == p_itr); + return true; } inline bool wc_match(const std::string& wild_card, const std::string& str) { return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } @@ -666,8 +667,10 @@ namespace exprtk const std::string& str) { return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } @@ -688,19 +691,19 @@ namespace exprtk itr_t p_itr = pattern.begin(); itr_t s_itr = str .begin(); - itr_t p_end = pattern.end(); - itr_t s_end = str .end(); + const itr_t p_end = pattern.end(); + const itr_t s_end = str .end(); while ((s_end != s_itr) && (p_end != p_itr)) { if ('*' == (*p_itr)) { - const char_t target = static_cast(std::toupper(*(p_itr - 1))); + const char_t target = static_cast(std::toupper(*(p_itr - 1))); if ('*' == target) { diff_index = static_cast(std::distance(str.begin(),s_itr)); - diff_value = static_cast(std::toupper(*p_itr)); + diff_value = static_cast(std::toupper(*p_itr)); return false; } @@ -723,7 +726,7 @@ namespace exprtk ) { diff_index = static_cast(std::distance(str.begin(),s_itr)); - diff_value = static_cast(std::toupper(*p_itr)); + diff_value = static_cast(std::toupper(*p_itr)); return false; } @@ -782,15 +785,15 @@ namespace exprtk }; #define exprtk_register_real_type_tag(T) \ - template<> struct number_type \ + template <> struct number_type \ { typedef real_type_tag type; number_type() {} }; \ #define exprtk_register_complex_type_tag(T) \ - template<> struct number_type > \ + template <> struct number_type > \ { typedef complex_type_tag type; number_type() {} }; \ #define exprtk_register_int_type_tag(T) \ - template<> struct number_type \ + template <> struct number_type \ { typedef int_type_tag type; number_type() {} }; \ exprtk_register_real_type_tag(double ) @@ -812,34 +815,23 @@ namespace exprtk #undef exprtk_register_int_type_tag template - struct epsilon_type - { - static inline T value() - { - const T epsilon = T(0.0000000001); - return epsilon; - } - }; + struct epsilon_type {}; - template <> - struct epsilon_type - { - static inline float value() - { - const float epsilon = float(0.000001f); - return epsilon; - } - }; + #define exprtk_define_epsilon_type(Type, Epsilon) \ + template <> struct epsilon_type \ + { \ + static inline Type value() \ + { \ + const Type epsilon = static_cast(Epsilon); \ + return epsilon; \ + } \ + }; \ - template <> - struct epsilon_type - { - static inline long double value() - { - const long double epsilon = (long double)(0.000000000001); - return epsilon; - } - }; + exprtk_define_epsilon_type(float , 0.00000100000f) + exprtk_define_epsilon_type(double , 0.000000000100) + exprtk_define_epsilon_type(long double, 0.000000000001) + + #undef exprtk_define_epsilon_type template inline bool is_nan_impl(const T v, real_type_tag) @@ -1037,7 +1029,7 @@ namespace exprtk template inline T roundn_impl(const T v0, const T v1, real_type_tag) { - const int index = std::max(0, std::min(pow10_size - 1, (int)std::floor(v1))); + const int index = std::max(0, std::min(pow10_size - 1, static_cast(std::floor(v1)))); const T p10 = T(pow10[index]); if (v0 < T(0)) @@ -1103,7 +1095,7 @@ namespace exprtk template inline T sgn_impl(const T v, real_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1111,7 +1103,7 @@ namespace exprtk template inline T sgn_impl(const T v, int_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1201,8 +1193,8 @@ namespace exprtk } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erf(TT,impl) \ - inline TT erf_impl(TT v) { return impl(v); } \ + #define exprtk_define_erf(TT, impl) \ + inline TT erf_impl(const TT v) { return impl(v); } \ exprtk_define_erf( float,::erff) exprtk_define_erf( double,::erf ) @@ -1211,7 +1203,7 @@ namespace exprtk #endif template - inline T erf_impl(T v, real_type_tag) + inline T erf_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) // Credits: Abramowitz & Stegun Equations 7.1.25-28 @@ -1225,12 +1217,12 @@ namespace exprtk const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); - T result = T(1) - t * std::exp((-v * v) - - c[0] + t * (c[1] + t * - (c[2] + t * (c[3] + t * - (c[4] + t * (c[5] + t * - (c[6] + t * (c[7] + t * - (c[8] + t * (c[9])))))))))); + const T result = T(1) - t * std::exp((-v * v) - + c[0] + t * (c[1] + t * + (c[2] + t * (c[3] + t * + (c[4] + t * (c[5] + t * + (c[6] + t * (c[7] + t * + (c[8] + t * (c[9])))))))))); return (v >= T(0)) ? result : -result; #else @@ -1239,23 +1231,23 @@ namespace exprtk } template - inline T erf_impl(T v, int_type_tag) + inline T erf_impl(const T v, int_type_tag) { return erf_impl(static_cast(v),real_type_tag()); } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erfc(TT,impl) \ - inline TT erfc_impl(TT v) { return impl(v); } \ + #define exprtk_define_erfc(TT, impl) \ + inline TT erfc_impl(const TT v) { return impl(v); } \ - exprtk_define_erfc( float,::erfcf) - exprtk_define_erfc( double,::erfc ) + exprtk_define_erfc(float ,::erfcf) + exprtk_define_erfc(double ,::erfc ) exprtk_define_erfc(long double,::erfcl) #undef exprtk_define_erfc #endif template - inline T erfc_impl(T v, real_type_tag) + inline T erfc_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) return T(1) - erf_impl(v,real_type_tag()); @@ -1265,28 +1257,28 @@ namespace exprtk } template - inline T erfc_impl(T v, int_type_tag) + inline T erfc_impl(const T v, int_type_tag) { return erfc_impl(static_cast(v),real_type_tag()); } template - inline T ncdf_impl(T v, real_type_tag) + inline T ncdf_impl(const T v, real_type_tag) { - T cnd = T(0.5) * (T(1) + erf_impl( - abs_impl(v,real_type_tag()) / - T(numeric::constant::sqrt2),real_type_tag())); + const T cnd = T(0.5) * (T(1) + + erf_impl(abs_impl(v,real_type_tag()) / + T(numeric::constant::sqrt2),real_type_tag())); return (v < T(0)) ? (T(1) - cnd) : cnd; } template - inline T ncdf_impl(T v, int_type_tag) + inline T ncdf_impl(const T v, int_type_tag) { return ncdf_impl(static_cast(v),real_type_tag()); } template - inline T sinc_impl(T v, real_type_tag) + inline T sinc_impl(const T v, real_type_tag) { if (std::abs(v) >= std::numeric_limits::epsilon()) return(std::sin(v) / v); @@ -1295,7 +1287,7 @@ namespace exprtk } template - inline T sinc_impl(T v, int_type_tag) + inline T sinc_impl(const T v, int_type_tag) { return sinc_impl(static_cast(v),real_type_tag()); } @@ -1326,14 +1318,15 @@ namespace exprtk template inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } template inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } template inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } - template inline T d2g_impl(const T v, real_type_tag) { return (v * T(20.0/9.0)); } - template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/20.0)); } + template inline T d2g_impl(const T v, real_type_tag) { return (v * T(10.0/9.0)); } + template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/10.0)); } template inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to()(T(0),v) ? T(0) : T(1)); } template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } - template inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } - template inline T const_e_impl (real_type_tag) { return T(numeric::constant::e); } + template inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } + template inline T const_e_impl(real_type_tag) { return T(numeric::constant::e); } + template inline T const_qnan_impl(real_type_tag) { return std::numeric_limits::quiet_NaN(); } template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } template inline T exp_impl(const T v, int_type_tag) { return std::exp (v); } @@ -1381,10 +1374,10 @@ namespace exprtk template struct numeric_info { enum { length = 0, size = 32, bound_length = 0, min_exp = 0, max_exp = 0 }; }; - template<> struct numeric_info { enum { length = 10, size = 16, bound_length = 9}; }; - template<> struct numeric_info { enum { min_exp = -38, max_exp = +38}; }; - template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; - template<> struct numeric_info { enum { min_exp = -308, max_exp = +308}; }; + template <> struct numeric_info { enum { length = 10, size = 16, bound_length = 9 }; }; + template <> struct numeric_info { enum { min_exp = -38, max_exp = +38 }; }; + template <> struct numeric_info { enum { min_exp = -308, max_exp = +308 }; }; + template <> struct numeric_info { enum { min_exp = -308, max_exp = +308 }; }; template inline int to_int32(const T v) @@ -1557,31 +1550,31 @@ namespace exprtk while (k) { - if (k & 1) + if (1 == (k % 2)) { l *= v; --k; } v *= v; - k >>= 1; + k /= 2; } return l; } }; - template struct fast_exp { static inline T result(T v) { T v_5 = fast_exp::result(v); return v_5 * v_5; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_4 = fast_exp::result(v); return v_4 * v_4; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_3 = fast_exp::result(v); return v_3 * v_3; } }; - template struct fast_exp { static inline T result(T v) { return fast_exp::result(v) * v; } }; - template struct fast_exp { static inline T result(T v) { T v_2 = v * v; return v_2 * v_2; } }; - template struct fast_exp { static inline T result(T v) { return v * v * v; } }; - template struct fast_exp { static inline T result(T v) { return v * v; } }; - template struct fast_exp { static inline T result(T v) { return v; } }; - template struct fast_exp { static inline T result(T ) { return T(1); } }; + template struct fast_exp { static inline T result(const T v) { T v_5 = fast_exp::result(v); return v_5 * v_5; } }; + template struct fast_exp { static inline T result(const T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(const T v) { T v_4 = fast_exp::result(v); return v_4 * v_4; } }; + template struct fast_exp { static inline T result(const T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(const T v) { T v_3 = fast_exp::result(v); return v_3 * v_3; } }; + template struct fast_exp { static inline T result(const T v) { return fast_exp::result(v) * v; } }; + template struct fast_exp { static inline T result(const T v) { T v_2 = v * v; return v_2 * v_2; } }; + template struct fast_exp { static inline T result(const T v) { return v * v * v; } }; + template struct fast_exp { static inline T result(const T v) { return v * v; } }; + template struct fast_exp { static inline T result(const T v) { return v; } }; + template struct fast_exp { static inline T result(const T ) { return T(1); } }; #define exprtk_define_unary_function(FunctionName) \ template \ @@ -1716,7 +1709,7 @@ namespace exprtk bool return_result = true; unsigned int digit = 0; - const std::size_t length = static_cast(std::distance(itr,end)); + const std::size_t length = static_cast(std::distance(itr,end)); if (length <= 4) { @@ -1747,10 +1740,14 @@ namespace exprtk #endif - case 4 : exprtk_process_digit - case 3 : exprtk_process_digit - case 2 : exprtk_process_digit - case 1 : if ((digit = (*itr - zero))>= 10) { digit = 0; return_result = false; } + case 4 : exprtk_process_digit + case 3 : exprtk_process_digit + case 2 : exprtk_process_digit + case 1 : if ((digit = (*itr - zero))>= 10) + { + digit = 0; + return_result = false; + } #undef exprtk_process_digit } @@ -1803,7 +1800,7 @@ namespace exprtk } template - static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, bool negative) + static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, const bool negative) { static const char_t inf_uc[] = "INFINITY"; static const char_t inf_lc[] = "infinity"; @@ -1818,7 +1815,7 @@ namespace exprtk while (end != itr) { - if (*inf_itr == static_cast(*itr)) + if (*inf_itr == static_cast(*itr)) { ++itr; ++inf_itr; @@ -1839,8 +1836,8 @@ namespace exprtk template inline bool valid_exponent(const int exponent, numeric::details::real_type_tag) { - return (std::numeric_limits::min_exponent10 <= exponent) && - (exponent <= std::numeric_limits::max_exponent10) ; + using namespace details::numeric; + return (numeric_info::min_exp <= exponent) && (exponent <= numeric_info::max_exp); } template @@ -1874,7 +1871,8 @@ namespace exprtk #define parse_digit_2(d) \ if ((digit = (*itr - zero)) < 10) \ { d = d * T(10) + digit; } \ - else { break; } \ + else \ + { break; } \ ++itr; \ if ('.' != (*itr)) @@ -1885,14 +1883,7 @@ namespace exprtk while (end != itr) { - // Note: For 'physical' superscalar architectures it - // is advised that the following loop be: 4xPD1 and 1xPD2 unsigned int digit; - - #ifdef exprtk_enable_superscalar - parse_digit_1(d) - parse_digit_1(d) - #endif parse_digit_1(d) parse_digit_1(d) parse_digit_2(d) @@ -1913,12 +1904,6 @@ namespace exprtk while (end != itr) { unsigned int digit; - - #ifdef exprtk_enable_superscalar - parse_digit_1(tmp_d) - parse_digit_1(tmp_d) - parse_digit_1(tmp_d) - #endif parse_digit_1(tmp_d) parse_digit_1(tmp_d) parse_digit_2(tmp_d) @@ -1928,12 +1913,12 @@ namespace exprtk { instate = true; - const int exponent = static_cast(-std::distance(curr, itr)); + const int frac_exponent = static_cast(-std::distance(curr, itr)); - if (!valid_exponent(exponent, numeric::details::real_type_tag())) + if (!valid_exponent(frac_exponent, numeric::details::real_type_tag())) return false; - d += compute_pow10(tmp_d, exponent); + d += compute_pow10(tmp_d, frac_exponent); } #undef parse_digit_1 @@ -2065,8 +2050,8 @@ namespace exprtk loop_types loop_set; loop_runtime_check() - : loop_set(e_invalid), - max_loop_iterations(0) + : loop_set(e_invalid) + , max_loop_iterations(0) {} details::_uint64_t max_loop_iterations; @@ -2111,9 +2096,9 @@ namespace exprtk }; token() - : type(e_none), - value(""), - position(std::numeric_limits::max()) + : type(e_none) + , value("") + , position(std::numeric_limits::max()) {} void clear() @@ -2272,9 +2257,9 @@ namespace exprtk typedef details::char_t char_t; generator() - : base_itr_(0), - s_itr_ (0), - s_end_ (0) + : base_itr_(0) + , s_itr_ (0) + , s_end_ (0) { clear(); } @@ -2390,10 +2375,10 @@ namespace exprtk } } - inline std::string substr(const std::size_t& begin, const std::size_t& end) + inline std::string substr(const std::size_t& begin, const std::size_t& end) const { const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; - const details::char_cptr end_itr = ((base_itr_ + end) < s_end_) ? (base_itr_ + end) : s_end_; + const details::char_cptr end_itr = ((base_itr_ + end ) < s_end_) ? (base_itr_ + end ) : s_end_; return std::string(begin_itr,end_itr); } @@ -2410,14 +2395,14 @@ namespace exprtk private: - inline bool is_end(details::char_cptr itr) + inline bool is_end(details::char_cptr itr) const { return (s_end_ == itr); } - inline bool is_comment_start(details::char_cptr itr) + #ifndef exprtk_disable_comments + inline bool is_comment_start(details::char_cptr itr) const { - #ifndef exprtk_disable_comments const char_t c0 = *(itr + 0); const char_t c1 = *(itr + 1); @@ -2428,9 +2413,14 @@ namespace exprtk if (('/' == c0) && ('/' == c1)) return true; if (('/' == c0) && ('*' == c1)) return true; } - #endif return false; } + #else + inline bool is_comment_start(details::char_cptr) const + { + return false; + } + #endif inline void skip_whitespace() { @@ -2452,10 +2442,10 @@ namespace exprtk static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr) { mode = 0; - if ('#' == c0) { mode = 1; incr = 1; } + if ('#' == c0) { mode = 1; incr = 1; } else if ('/' == c0) { - if ('/' == c1) { mode = 1; incr = 2; } + if ('/' == c1) { mode = 1; incr = 2; } else if ('*' == c1) { mode = 2; incr = 2; } } return (0 != mode); @@ -2598,7 +2588,7 @@ namespace exprtk token_t::token_type ttype = token_t::e_none; - if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; + if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte; else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne; else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne; @@ -2785,7 +2775,10 @@ namespace exprtk // $fdd(x,x,x) = at least 11 chars if (std::distance(s_itr_,s_end_) < 11) { - t.set_error(token::e_err_sfunc, initial_itr, s_itr_, base_itr_); + t.set_error( + token::e_err_sfunc, + initial_itr, std::min(initial_itr + 11, s_end_), + base_itr_); token_list_.push_back(t); return; @@ -2798,7 +2791,10 @@ namespace exprtk (details::is_digit(*(s_itr_ + 3)))) ) { - t.set_error(token::e_err_sfunc, initial_itr, s_itr_, base_itr_); + t.set_error( + token::e_err_sfunc, + initial_itr, std::min(initial_itr + 4, s_end_), + base_itr_); token_list_.push_back(t); return; @@ -2930,7 +2926,7 @@ namespace exprtk friend class token_modifier; friend class token_inserter; friend class token_joiner; - }; + }; // class generator class helper_interface { @@ -2947,8 +2943,7 @@ namespace exprtk { public: - virtual ~token_scanner() - {} + virtual ~token_scanner() {} explicit token_scanner(const std::size_t& stride) : stride_(stride) @@ -2959,7 +2954,7 @@ namespace exprtk } } - inline std::size_t process(generator& g) + inline std::size_t process(generator& g) exprtk_override { if (g.token_list_.size() >= stride_) { @@ -3048,13 +3043,13 @@ namespace exprtk private: const std::size_t stride_; - }; + }; // class token_scanner class token_modifier : public helper_interface { public: - inline std::size_t process(generator& g) + inline std::size_t process(generator& g) exprtk_override { std::size_t changes = 0; @@ -3082,7 +3077,7 @@ namespace exprtk } } - inline std::size_t process(generator& g) + inline std::size_t process(generator& g) exprtk_override { if (g.token_list_.empty()) return 0; @@ -3186,7 +3181,7 @@ namespace exprtk : stride_(stride) {} - inline std::size_t process(generator& g) + inline std::size_t process(generator& g) exprtk_override { if (g.token_list_.empty()) return 0; @@ -3232,13 +3227,15 @@ namespace exprtk i+=2; - if (static_cast(i) >= g.token_list_.size()) + if (static_cast(i) >= (g.token_list_.size() - 1)) break; } } token_list.push_back(g.token_list_.back()); + assert(token_list.size() <= g.token_list_.size()); + std::swap(token_list, g.token_list_); return changes; @@ -3272,7 +3269,7 @@ namespace exprtk i+=3; - if (static_cast(i) >= g.token_list_.size()) + if (static_cast(i) >= (g.token_list_.size() - 2)) break; } } @@ -3280,6 +3277,8 @@ namespace exprtk token_list.push_back(*(g.token_list_.begin() + g.token_list_.size() - 2)); token_list.push_back(*(g.token_list_.begin() + g.token_list_.size() - 1)); + assert(token_list.size() <= g.token_list_.size()); + std::swap(token_list, g.token_list_); return changes; @@ -3345,7 +3344,7 @@ namespace exprtk return -1; } } - if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; + if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lbracket )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lcrlbracket)) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lsqrbracket)) match = true; @@ -3458,7 +3457,7 @@ namespace exprtk return true; } // '! =' --> '!=' - else if ((static_cast(t0.type) == '!') && (t1.type == lexer::token::e_eq)) + else if ((static_cast(t0.type) == '!') && (t1.type == lexer::token::e_eq)) { t.type = lexer::token::e_ne; t.value = "!="; @@ -3519,7 +3518,10 @@ namespace exprtk return false; } - inline bool join(const lexer::token& t0, const lexer::token& t1, const lexer::token& t2, lexer::token& t) + inline bool join(const lexer::token& t0, + const lexer::token& t1, + const lexer::token& t2, + lexer::token& t) { // '[ * ]' --> '[*]' if ( @@ -3546,8 +3548,8 @@ namespace exprtk using lexer::token_scanner::operator(); bracket_checker() - : token_scanner(1), - state_(true) + : token_scanner(1) + , state_(true) {} bool result() @@ -3590,7 +3592,7 @@ namespace exprtk { details::char_t c = t.value[0]; - if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); + if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); else if (exprtk::details::is_right_bracket(c)) @@ -3631,8 +3633,8 @@ namespace exprtk using lexer::token_scanner::operator(); numeric_checker() - : token_scanner (1), - current_index_(0) + : token_scanner (1) + , current_index_(0) {} bool result() @@ -3839,12 +3841,12 @@ namespace exprtk private: - void add_invalid(lexer::token::token_type base, lexer::token::token_type t) + void add_invalid(const lexer::token::token_type base, const lexer::token::token_type t) { invalid_comb_.insert(std::make_pair(base,t)); } - void add_invalid_set1(lexer::token::token_type t) + void add_invalid_set1(const lexer::token::token_type t) { add_invalid(t, lexer::token::e_assign); add_invalid(t, lexer::token::e_shr ); @@ -3863,9 +3865,9 @@ namespace exprtk add_invalid(t, lexer::token::e_colon ); } - bool invalid_bracket_check(lexer::token::token_type base, lexer::token::token_type t) + bool invalid_bracket_check(const lexer::token::token_type base, const lexer::token::token_type t) { - if (details::is_right_bracket(static_cast(base))) + if (details::is_right_bracket(static_cast(base))) { switch (t) { @@ -3874,11 +3876,11 @@ namespace exprtk default : return false; } } - else if (details::is_left_bracket(static_cast(base))) + else if (details::is_left_bracket(static_cast(base))) { - if (details::is_right_bracket(static_cast(t))) + if (details::is_right_bracket(static_cast(t))) return false; - else if (details::is_left_bracket(static_cast(t))) + else if (details::is_left_bracket(static_cast(t))) return false; else { @@ -3895,7 +3897,7 @@ namespace exprtk } } } - else if (details::is_right_bracket(static_cast(t))) + else if (details::is_right_bracket(static_cast(t))) { switch (base) { @@ -3908,7 +3910,7 @@ namespace exprtk default : return true ; } } - else if (details::is_left_bracket(static_cast(t))) + else if (details::is_left_bracket(static_cast(t))) { switch (base) { @@ -3941,23 +3943,23 @@ namespace exprtk sequence_validator_3tokens() : lexer::token_scanner(3) { - add_invalid(lexer::token::e_number, lexer::token::e_number, lexer::token::e_number); - add_invalid(lexer::token::e_string, lexer::token::e_string, lexer::token::e_string); - add_invalid(lexer::token::e_comma , lexer::token::e_comma , lexer::token::e_comma ); + add_invalid(lexer::token::e_number , lexer::token::e_number , lexer::token::e_number); + add_invalid(lexer::token::e_string , lexer::token::e_string , lexer::token::e_string); + add_invalid(lexer::token::e_comma , lexer::token::e_comma , lexer::token::e_comma ); - add_invalid(lexer::token::e_add , lexer::token::e_add , lexer::token::e_add ); - add_invalid(lexer::token::e_sub , lexer::token::e_sub , lexer::token::e_sub ); - add_invalid(lexer::token::e_div , lexer::token::e_div , lexer::token::e_div ); - add_invalid(lexer::token::e_mul , lexer::token::e_mul , lexer::token::e_mul ); - add_invalid(lexer::token::e_mod , lexer::token::e_mod , lexer::token::e_mod ); - add_invalid(lexer::token::e_pow , lexer::token::e_pow , lexer::token::e_pow ); + add_invalid(lexer::token::e_add , lexer::token::e_add , lexer::token::e_add ); + add_invalid(lexer::token::e_sub , lexer::token::e_sub , lexer::token::e_sub ); + add_invalid(lexer::token::e_div , lexer::token::e_div , lexer::token::e_div ); + add_invalid(lexer::token::e_mul , lexer::token::e_mul , lexer::token::e_mul ); + add_invalid(lexer::token::e_mod , lexer::token::e_mod , lexer::token::e_mod ); + add_invalid(lexer::token::e_pow , lexer::token::e_pow , lexer::token::e_pow ); - add_invalid(lexer::token::e_add , lexer::token::e_sub , lexer::token::e_add ); - add_invalid(lexer::token::e_sub , lexer::token::e_add , lexer::token::e_sub ); - add_invalid(lexer::token::e_div , lexer::token::e_mul , lexer::token::e_div ); - add_invalid(lexer::token::e_mul , lexer::token::e_div , lexer::token::e_mul ); - add_invalid(lexer::token::e_mod , lexer::token::e_pow , lexer::token::e_mod ); - add_invalid(lexer::token::e_pow , lexer::token::e_mod , lexer::token::e_pow ); + add_invalid(lexer::token::e_add , lexer::token::e_sub , lexer::token::e_add ); + add_invalid(lexer::token::e_sub , lexer::token::e_add , lexer::token::e_sub ); + add_invalid(lexer::token::e_div , lexer::token::e_mul , lexer::token::e_div ); + add_invalid(lexer::token::e_mul , lexer::token::e_div , lexer::token::e_mul ); + add_invalid(lexer::token::e_mod , lexer::token::e_pow , lexer::token::e_mod ); + add_invalid(lexer::token::e_pow , lexer::token::e_mod , lexer::token::e_pow ); } bool result() @@ -4002,7 +4004,7 @@ namespace exprtk private: - void add_invalid(token_t t0, token_t t1, token_t t2) + void add_invalid(const token_t t0, const token_t t1, const token_t t2) { invalid_comb_.insert(std::make_pair(t0,std::make_pair(t1,t2))); } @@ -4173,7 +4175,7 @@ namespace exprtk { public: - typedef token token_t; + typedef token token_t; typedef generator generator_t; inline bool init(const std::string& str) @@ -4291,15 +4293,15 @@ namespace exprtk typedef T* data_ptr_t; vector_view(data_ptr_t data, const std::size_t& size) - : size_(size), - data_(data), - data_ref_(0) + : size_(size) + , data_(data) + , data_ref_(0) {} vector_view(const vector_view& vv) - : size_(vv.size_), - data_(vv.data_), - data_ref_(0) + : size_(vv.size_) + , data_(vv.data_) + , data_ref_(0) {} inline void rebase(data_ptr_t data) @@ -4375,15 +4377,15 @@ namespace exprtk }; type_store() - : data(0), - size(0), - type(e_unknown) + : data(0) + , size(0) + , type(e_unknown) {} union { - void* data; - T* vec_data; + void* data; + T* vec_data; }; std::size_t size; @@ -4393,7 +4395,7 @@ namespace exprtk { public: - parameter_list(std::vector& pl) + explicit parameter_list(std::vector& pl) : parameter_list_(pl) {} @@ -4450,14 +4452,14 @@ namespace exprtk typedef type_store type_store_t; typedef ViewType value_t; - type_view(type_store_t& ts) - : ts_(ts), - data_(reinterpret_cast(ts_.data)) + explicit type_view(type_store_t& ts) + : ts_(ts) + , data_(reinterpret_cast(ts_.data)) {} - type_view(const type_store_t& ts) - : ts_(const_cast(ts)), - data_(reinterpret_cast(ts_.data)) + explicit type_view(const type_store_t& ts) + : ts_(const_cast(ts)) + , data_(reinterpret_cast(ts_.data)) {} inline std::size_t size() const @@ -4500,11 +4502,11 @@ namespace exprtk typedef type_store type_store_t; typedef T value_t; - scalar_view(type_store_t& ts) + explicit scalar_view(type_store_t& ts) : v_(*reinterpret_cast(ts.data)) {} - scalar_view(const type_store_t& ts) + explicit scalar_view(const type_store_t& ts) : v_(*reinterpret_cast(const_cast(ts).data)) {} @@ -4725,8 +4727,8 @@ namespace exprtk struct base_operation_t { base_operation_t(const operator_type t, const unsigned int& np) - : type(t), - num_params(np) + : type(t) + , num_params(np) {} operator_type type; @@ -4745,13 +4747,13 @@ namespace exprtk { explicit details(const std::size_t& vsize, const unsigned int loop_batch_size = global_loop_batch_size) - : batch_size(loop_batch_size ), - remainder (vsize % batch_size), - upper_bound(static_cast(vsize - (remainder ? loop_batch_size : 0))) + : batch_size(loop_batch_size ) + , remainder (vsize % batch_size) + , upper_bound(static_cast(vsize - (remainder ? loop_batch_size : 0))) {} unsigned int batch_size; - int remainder; + int remainder; int upper_bound; }; } @@ -4785,24 +4787,24 @@ namespace exprtk struct control_block { control_block() - : ref_count(1), - size (0), - data (0), - destruct (true) + : ref_count(1) + , size (0) + , data (0) + , destruct (true) {} - control_block(const std::size_t& dsize) - : ref_count(1 ), - size (dsize), - data (0 ), - destruct (true ) + explicit control_block(const std::size_t& dsize) + : ref_count(1 ) + , size (dsize) + , data (0 ) + , destruct (true ) { create_data(); } control_block(const std::size_t& dsize, data_t dptr, bool dstrct = false) - : ref_count(1 ), - size (dsize ), - data (dptr ), - destruct (dstrct) + : ref_count(1 ) + , size (dsize ) + , data (dptr ) + , destruct (dstrct) {} ~control_block() @@ -4851,15 +4853,15 @@ namespace exprtk private: - control_block(const control_block&); - control_block& operator=(const control_block&); + control_block(const control_block&) exprtk_delete; + control_block& operator=(const control_block&) exprtk_delete; inline void create_data() { destruct = true; data = new T[size]; std::fill_n(data, size, T(0)); - dump_ptr("control_block::create_data() - data",data,size); + dump_ptr("control_block::create_data() - data", data, size); } }; @@ -4869,8 +4871,8 @@ namespace exprtk : control_block_(control_block::create(0)) {} - vec_data_store(const std::size_t& size) - : control_block_(control_block::create(size,(data_t)(0),true)) + explicit vec_data_store(const std::size_t& size) + : control_block_(control_block::create(size,reinterpret_cast(0),true)) {} vec_data_store(const std::size_t& size, data_t data, bool dstrct = false) @@ -4919,11 +4921,6 @@ namespace exprtk return control_block_->data; } - inline std::size_t size() - { - return control_block_->size; - } - inline std::size_t size() const { return control_block_->size; @@ -4962,7 +4959,7 @@ namespace exprtk private: - static inline std::size_t min_size(control_block* cb0, control_block* cb1) + static inline std::size_t min_size(const control_block* cb0, const control_block* cb1) { const std::size_t size0 = cb0->size; const std::size_t size1 = cb1->size; @@ -5181,8 +5178,8 @@ namespace exprtk e_vecdefass , e_vecvalass , e_vecvecass , e_vecopvalass , e_vecopvecass , e_vecfunc , e_vecvecswap , e_vecvecineq , e_vecvalineq , e_valvecineq , e_vecvecarith , e_vecvalarith , - e_valvecarith , e_vecunaryop , e_break , e_continue , - e_swap + e_valvecarith , e_vecunaryop , e_vecondition , e_break , + e_continue , e_swap }; typedef T value_type; @@ -5191,8 +5188,7 @@ namespace exprtk typedef typename nci_t::noderef_list_t noderef_list_t; typedef node_depth_base > ndb_t; - virtual ~expression_node() - {} + virtual ~expression_node() {} inline virtual T value() const { @@ -5208,7 +5204,7 @@ namespace exprtk { return e_none; } - }; + }; // class expression_node template inline bool is_generally_string_node(const expression_node* node); @@ -5334,7 +5330,8 @@ namespace exprtk case details::expression_node::e_vecvecarith : case details::expression_node::e_vecvalarith : case details::expression_node::e_valvecarith : - case details::expression_node::e_vecunaryop : return true; + case details::expression_node::e_vecunaryop : + case details::expression_node::e_vecondition : return true; default : return false; } } @@ -5577,9 +5574,12 @@ namespace exprtk template struct node_depth_base { + typedef Node* node_ptr_t; + typedef std::pair nb_pair_t; + node_depth_base() - : depth_set(false), - depth(0) + : depth_set(false) + , depth(0) {} virtual ~node_depth_base() {} @@ -5597,7 +5597,7 @@ namespace exprtk return depth; } - std::size_t compute_node_depth(const std::pair& branch) const + std::size_t compute_node_depth(const nb_pair_t& branch) const { if (!depth_set) { @@ -5609,7 +5609,7 @@ namespace exprtk } template - std::size_t compute_node_depth(const std::pair (&branch)[N]) const + std::size_t compute_node_depth(const nb_pair_t (&branch)[N]) const { if (!depth_set) { @@ -5672,7 +5672,7 @@ namespace exprtk template class Sequence> - std::size_t compute_node_depth(const Sequence& branch_list) const + std::size_t compute_node_depth(const Sequence& branch_list) const { if (!depth_set) { @@ -5691,7 +5691,7 @@ namespace exprtk template class Sequence> - std::size_t compute_node_depth(const Sequence,Allocator>& branch_list) const + std::size_t compute_node_depth(const Sequence& branch_list) const { if (!depth_set) { @@ -5712,18 +5712,18 @@ namespace exprtk mutable std::size_t depth; template - void collect(Node*const& node, + void collect(node_ptr_t const& node, const bool deletable, NodeSequence& delete_node_list) const { if ((0 != node) && deletable) { - delete_node_list.push_back(const_cast(&node)); + delete_node_list.push_back(const_cast(&node)); } } template - void collect(const std::pair& branch, + void collect(const nb_pair_t& branch, NodeSequence& delete_node_list) const { collect(branch.first, branch.second, delete_node_list); @@ -5737,7 +5737,7 @@ namespace exprtk } template - void collect(const std::pair(&branch)[N], + void collect(const nb_pair_t(&branch)[N], NodeSequence& delete_node_list) const { for (std::size_t i = 0; i < N; ++i) @@ -5749,7 +5749,7 @@ namespace exprtk template class Sequence, typename NodeSequence> - void collect(const Sequence, Allocator>& branch, + void collect(const Sequence& branch, NodeSequence& delete_node_list) const { for (std::size_t i = 0; i < branch.size(); ++i) @@ -5761,7 +5761,7 @@ namespace exprtk template class Sequence, typename NodeSequence> - void collect(const Sequence& branch_list, + void collect(const Sequence& branch_list, NodeSequence& delete_node_list) const { for (std::size_t i = 0; i < branch_list.size(); ++i) @@ -5775,7 +5775,7 @@ namespace exprtk typename AllocatorB, template class Sequence, typename NodeSequence> - void collect(const Sequence& branch_list, + void collect(const Sequence& branch_list, const Sequence& branch_deletable_list, NodeSequence& delete_node_list) const { @@ -5834,8 +5834,8 @@ namespace exprtk public: array_vector_impl(const Type* vec, const std::size_t& vec_size) - : vec_(vec), - size_(vec_size) + : vec_(vec) + , size_(vec_size) {} protected: @@ -5855,7 +5855,8 @@ namespace exprtk private: - array_vector_impl operator=(const array_vector_impl&); + array_vector_impl(const array_vector_impl&) exprtk_delete; + array_vector_impl& operator=(const array_vector_impl&) exprtk_delete; const Type* vec_; const std::size_t size_; @@ -5887,7 +5888,8 @@ namespace exprtk private: - sequence_vector_impl operator=(const sequence_vector_impl&); + sequence_vector_impl(const sequence_vector_impl&) exprtk_delete; + sequence_vector_impl& operator=(const sequence_vector_impl&) exprtk_delete; sequence_t& sequence_; }; @@ -5926,7 +5928,8 @@ namespace exprtk private: - vector_view_impl operator=(const vector_view_impl&); + vector_view_impl(const vector_view_impl&) exprtk_delete; + vector_view_impl& operator=(const vector_view_impl&) exprtk_delete; vector_view_t& vec_view_; }; @@ -5984,16 +5987,16 @@ namespace exprtk }; template - class null_node : public expression_node + class null_node exprtk_final : public expression_node { public: - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_null; } @@ -6045,7 +6048,7 @@ namespace exprtk } template - class null_eq_node : public expression_node + class null_eq_node exprtk_final : public expression_node { public: @@ -6058,7 +6061,7 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6071,27 +6074,22 @@ namespace exprtk return (equality_) ? T(0) : T(1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_nulleq; } - inline operator_type operation() const - { - return details::e_eq; - } - - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(branch_,node_delete_list); + expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6103,7 +6101,7 @@ namespace exprtk }; template - class literal_node : public expression_node + class literal_node exprtk_final : public expression_node { public: @@ -6111,25 +6109,25 @@ namespace exprtk : value_(v) {} - inline T value() const + inline T value() const exprtk_override { return value_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_constant; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } private: - literal_node(literal_node&) {} - literal_node& operator=(literal_node&) { return (*this); } + literal_node(const literal_node&) exprtk_delete; + literal_node& operator=(const literal_node&) exprtk_delete; const T value_; }; @@ -6147,8 +6145,7 @@ namespace exprtk typedef range_pack range_t; - virtual ~range_interface() - {} + virtual ~range_interface() {} virtual range_t& range_ref() = 0; @@ -6163,8 +6160,7 @@ namespace exprtk typedef range_data_type range_data_type_t; - virtual ~string_base_node() - {} + virtual ~string_base_node() {} virtual std::string str () const = 0; @@ -6174,7 +6170,8 @@ namespace exprtk }; template - class string_literal_node : public expression_node , + class string_literal_node exprtk_final + : public expression_node , public string_base_node, public range_interface { @@ -6191,50 +6188,50 @@ namespace exprtk rp_.cache.second = rp_.n1_c.second; } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringconst; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } private: - string_literal_node(const string_literal_node&); - string_literal_node& operator=(const string_literal_node&); + string_literal_node(const string_literal_node&) exprtk_delete; + string_literal_node& operator=(const string_literal_node&) exprtk_delete; const std::string value_; range_t rp_; @@ -6255,7 +6252,7 @@ namespace exprtk construct_branch_pair(branch_,branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6264,17 +6261,17 @@ namespace exprtk return numeric::process(operation_,arg); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_unary; } - inline operator_type operation() const + inline operator_type operation() { return operation_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -6284,12 +6281,12 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6316,7 +6313,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6327,7 +6324,7 @@ namespace exprtk return numeric::process(operation_,arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary; } @@ -6337,7 +6334,7 @@ namespace exprtk return operation_; } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6347,12 +6344,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6364,7 +6361,7 @@ namespace exprtk }; template - class binary_ext_node : public expression_node + class binary_ext_node exprtk_final : public expression_node { public: @@ -6376,7 +6373,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6387,7 +6384,7 @@ namespace exprtk return Operation::process(arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary_ext; } @@ -6397,7 +6394,7 @@ namespace exprtk return Operation::operation(); } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6407,12 +6404,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6439,7 +6436,7 @@ namespace exprtk init_branches<3>(branch_, branch0, branch1, branch2); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6465,17 +6462,17 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<3>(branch_); } @@ -6504,22 +6501,22 @@ namespace exprtk init_branches<4>(branch_, branch0, branch1, branch2, branch3); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_quaternary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<4>(branch_); } @@ -6531,7 +6528,7 @@ namespace exprtk }; template - class conditional_node : public expression_node + class conditional_node exprtk_final : public expression_node { public: @@ -6547,7 +6544,7 @@ namespace exprtk construct_branch_pair(alternative_, alternative); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_ .first); @@ -6559,19 +6556,19 @@ namespace exprtk return alternative_.first->value(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(consequent_ , node_delete_list); - expression_node::ndb_t::collect(alternative_, node_delete_list); + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(consequent_ , node_delete_list); + expression_node::ndb_t::collect(alternative_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (condition_, consequent_, alternative_); @@ -6585,7 +6582,7 @@ namespace exprtk }; template - class cons_conditional_node : public expression_node + class cons_conditional_node exprtk_final : public expression_node { public: @@ -6600,7 +6597,7 @@ namespace exprtk construct_branch_pair(consequent_, consequent); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_.first); @@ -6611,18 +6608,18 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(consequent_, node_delete_list); + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(consequent_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t:: compute_node_depth(condition_, consequent_); @@ -6640,18 +6637,17 @@ namespace exprtk { public: - break_exception(const T& v) + explicit break_exception(const T& v) : value(v) {} T value; }; - class continue_exception - {}; + class continue_exception {}; template - class break_node : public expression_node + class break_node exprtk_final : public expression_node { public: @@ -6663,25 +6659,30 @@ namespace exprtk construct_branch_pair(return_, ret); } - inline T value() const + inline T value() const exprtk_override { - throw break_exception(return_.first ? return_.first->value() : std::numeric_limits::quiet_NaN()); + const T result = return_.first ? + return_.first->value() : + std::numeric_limits::quiet_NaN(); + + throw break_exception(result); + #ifndef _MSC_VER return std::numeric_limits::quiet_NaN(); #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(return_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(return_); } @@ -6692,11 +6693,11 @@ namespace exprtk }; template - class continue_node : public expression_node + class continue_node exprtk_final : public expression_node { public: - inline T value() const + inline T value() const exprtk_override { throw continue_exception(); #ifndef _MSC_VER @@ -6704,22 +6705,24 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } }; #endif - #ifdef exprtk_enable_runtime_checks struct loop_runtime_checker { - loop_runtime_checker(loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0), + loop_runtime_checker(loop_runtime_check_ptr loop_runtime_check, loop_runtime_check::loop_types lp_typ = loop_runtime_check::e_invalid) - : iteration_count_(0), - loop_runtime_check_(loop_rt_chk), - loop_type(lp_typ) - {} + : iteration_count_(0) + , loop_runtime_check_(loop_runtime_check) + , max_loop_iterations_(loop_runtime_check_->max_loop_iterations) + , loop_type_(lp_typ) + { + assert(loop_runtime_check_); + } inline void reset(const _uint64_t initial_value = 0) const { @@ -6730,14 +6733,14 @@ namespace exprtk { if ( (0 == loop_runtime_check_) || - (++iteration_count_ <= loop_runtime_check_->max_loop_iterations) + (++iteration_count_ <= max_loop_iterations_) ) { return true; } loop_runtime_check::violation_context ctxt; - ctxt.loop = loop_type; + ctxt.loop = loop_type_; ctxt.violation = loop_runtime_check::e_iteration_count; loop_runtime_check_->handle_runtime_violation(ctxt); @@ -6747,27 +6750,12 @@ namespace exprtk mutable _uint64_t iteration_count_; mutable loop_runtime_check_ptr loop_runtime_check_; - loop_runtime_check::loop_types loop_type; + const details::_uint64_t& max_loop_iterations_; + loop_runtime_check::loop_types loop_type_; }; - #else - struct loop_runtime_checker - { - loop_runtime_checker(loop_runtime_check_ptr, loop_runtime_check::loop_types) - {} - - inline void reset(const _uint64_t = 0) const - {} - - inline bool check() const - { - return true; - } - }; - #endif template - class while_loop_node : public expression_node, - public loop_runtime_checker + class while_loop_node : public expression_node { public: @@ -6775,24 +6763,20 @@ namespace exprtk typedef std::pair branch_t; while_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk,loop_runtime_check::e_while_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6800,31 +6784,65 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_while; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(condition_, node_delete_list); - expression_node::ndb_t::collect(loop_body_, node_delete_list); + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); } - private: + protected: branch_t condition_; branch_t loop_body_; }; template - class repeat_until_loop_node : public expression_node, - public loop_runtime_checker + class while_loop_rtc_node exprtk_final + : public while_loop_node + , public loop_runtime_checker + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + + return result; + } + }; + + template + class repeat_until_loop_node : public expression_node { public: @@ -6832,57 +6850,88 @@ namespace exprtk typedef std::pair branch_t; repeat_until_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); + do + { + result = loop_body_.first->value(); + } + while (is_false(condition_.first)); + + return result; + } + + inline typename expression_node::node_type type() const exprtk_override + { + return expression_node::e_repeat; + } + + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override + { + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(loop_body_ , node_delete_list); + } + + std::size_t node_depth() const exprtk_override + { + return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); + } + + protected: + + branch_t condition_; + branch_t loop_body_; + }; + + template + class repeat_until_loop_rtc_node exprtk_final + : public repeat_until_loop_node + , public loop_runtime_checker + { + public: + + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; + + repeat_until_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + loop_runtime_checker::reset(1); do { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); return result; } - - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } - - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_, node_delete_list); - expression_node::ndb_t::collect(loop_body_, node_delete_list); - } - - std::size_t node_depth() const - { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } - - private: - - branch_t condition_; - branch_t loop_body_; }; template - class for_loop_node : public expression_node, - public loop_runtime_checker + class for_loop_node : public expression_node { public: @@ -6892,9 +6941,7 @@ namespace exprtk for_loop_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + expression_ptr loop_body) { construct_branch_pair(initialiser_, initialiser); construct_branch_pair(condition_ , condition ); @@ -6902,21 +6949,19 @@ namespace exprtk construct_branch_pair(loop_body_ , loop_body ); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - if (initialiser_.first) initialiser_.first->value(); if (incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); incrementor_.first->value(); @@ -6924,7 +6969,7 @@ namespace exprtk } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6933,26 +6978,26 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_for; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(initialiser_, node_delete_list); - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(incrementor_, node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); + expression_node::ndb_t::collect(initialiser_ , node_delete_list); + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(incrementor_ , node_delete_list); + expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (initialiser_, condition_, incrementor_, loop_body_); } - private: + protected: branch_t initialiser_; branch_t condition_ ; @@ -6960,39 +7005,83 @@ namespace exprtk branch_t loop_body_ ; }; - #ifndef exprtk_disable_break_continue template - class while_loop_bc_node : public expression_node, - public loop_runtime_checker + class for_loop_rtc_node exprtk_final + : public for_loop_node + , public loop_runtime_checker { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; - while_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + for_loop_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); loop_runtime_checker::reset(); - while (is_true(condition_) && loop_runtime_checker::check()) + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + } + + return result; + } + }; + + #ifndef exprtk_disable_break_continue + template + class while_loop_bc_node : public while_loop_node + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_node(expression_ptr condition, + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7004,51 +7093,112 @@ namespace exprtk return result; } - - inline typename expression_node::node_type type() const - { - return expression_node::e_while; - } - - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_, node_delete_list); - expression_node::ndb_t::collect(loop_body_, node_delete_list); - } - - std::size_t node_depth() const - { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } - - private: - - branch_t condition_; - branch_t loop_body_; }; template - class repeat_until_loop_bc_node : public expression_node, - public loop_runtime_checker + class while_loop_bc_rtc_node exprtk_final + : public while_loop_bc_node + , public loop_runtime_checker { public: - typedef expression_node* expression_ptr; - typedef std::pair branch_t; + typedef while_loop_bc_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + + return result; + } + }; + + template + class repeat_until_loop_bc_node : public repeat_until_loop_node + { + public: + + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; repeat_until_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + do + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + while (is_false(parent_t::condition_.first)); + + return result; + } + }; + + template + class repeat_until_loop_bc_rtc_node exprtk_final + : public repeat_until_loop_bc_node, + public loop_runtime_checker + { + public: + + typedef repeat_until_loop_bc_node parent_t; + typedef expression_node* expression_ptr; + + repeat_until_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); @@ -7058,7 +7208,7 @@ namespace exprtk { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7067,74 +7217,114 @@ namespace exprtk catch(const continue_exception&) {} } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); return result; } - - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } - - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_, node_delete_list); - expression_node::ndb_t::collect(loop_body_, node_delete_list); - } - - std::size_t node_depth() const - { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } - - private: - - branch_t condition_; - branch_t loop_body_; }; template - class for_loop_bc_node : public expression_node, - public loop_runtime_checker + class for_loop_bc_node : public for_loop_node { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; for_loop_bc_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) - { - construct_branch_pair(initialiser_, initialiser); - construct_branch_pair(condition_ , condition ); - construct_branch_pair(incrementor_, incrementor); - construct_branch_pair(loop_body_ , loop_body ); - } + expression_ptr loop_body) + : parent_t(initialiser, condition, incrementor, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_)) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_)) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + } + + return result; + } + }; + + template + class for_loop_bc_rtc_node exprtk_final + : public for_loop_bc_node + , public loop_runtime_checker + { + public: + + typedef for_loop_bc_node parent_t; + typedef expression_node* expression_ptr; + + for_loop_bc_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); loop_runtime_checker::reset(); - if (initialiser_.first) - initialiser_.first->value(); + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); - if (incrementor_.first) + if (parent_t::incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7143,16 +7333,16 @@ namespace exprtk catch(const continue_exception&) {} - incrementor_.first->value(); + parent_t::incrementor_.first->value(); } } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7165,32 +7355,6 @@ namespace exprtk return result; } - - inline typename expression_node::node_type type() const - { - return expression_node::e_for; - } - - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(initialiser_, node_delete_list); - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(incrementor_, node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } - - std::size_t node_depth() const - { - return expression_node::ndb_t::compute_node_depth - (initialiser_, condition_, incrementor_, loop_body_); - } - - private: - - branch_t initialiser_; - branch_t condition_ ; - branch_t incrementor_; - branch_t loop_body_ ; }; #endif @@ -7225,7 +7389,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) { @@ -7248,17 +7412,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_switch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7269,7 +7433,7 @@ namespace exprtk }; template - class switch_n_node : public switch_node + class switch_n_node exprtk_final : public switch_node { public: @@ -7281,14 +7445,14 @@ namespace exprtk : switch_node(arg_list) {} - inline T value() const + inline T value() const exprtk_override { return Switch_N::process(switch_node::arg_list_); } }; template - class multi_switch_node : public expression_node + class multi_switch_node exprtk_final : public expression_node { public: @@ -7318,7 +7482,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = T(0); @@ -7343,17 +7507,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_mswitch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7368,15 +7532,15 @@ namespace exprtk { public: - virtual ~ivariable() - {} + virtual ~ivariable() {} virtual T& ref() = 0; virtual const T& ref() const = 0; }; template - class variable_node : public expression_node, + class variable_node exprtk_final + : public expression_node, public ivariable { public: @@ -7396,22 +7560,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return (*value_); } - inline T& ref() + inline T& ref() exprtk_override { return (*value_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return (*value_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_variable; } @@ -7431,11 +7595,11 @@ namespace exprtk typedef std::pair cached_range_t; range_pack() - : n0_e (std::make_pair(false,expression_node_ptr(0))), - n1_e (std::make_pair(false,expression_node_ptr(0))), - n0_c (std::make_pair(false,0)), - n1_c (std::make_pair(false,0)), - cache(std::make_pair(0,0)) + : n0_e (std::make_pair(false,expression_node_ptr(0))) + , n1_e (std::make_pair(false,expression_node_ptr(0))) + , n0_c (std::make_pair(false,0)) + , n1_c (std::make_pair(false,0)) + , cache(std::make_pair(0,0)) {} void clear() @@ -7520,7 +7684,7 @@ namespace exprtk cache.first = r0; cache.second = r1; - #ifndef exprtk_enable_runtime_checks + #ifndef exprtk_enable_range_runtime_checks return (r0 <= r1); #else return range_runtime_check(r0, r1, size); @@ -7543,18 +7707,18 @@ namespace exprtk std::pair n1_c; mutable cached_range_t cache; - #ifdef exprtk_enable_runtime_checks + #ifdef exprtk_enable_range_runtime_checks bool range_runtime_check(const std::size_t r0, const std::size_t r1, const std::size_t size) const { - if ((r0 < 0) || (r0 >= size)) + if (r0 >= size) { throw std::runtime_error("range error: (r0 < 0) || (r0 >= size)"); return false; } - if ((r1 < 0) || (r1 >= size)) + if (r1 >= size) { throw std::runtime_error("range error: (r1 < 0) || (r1 >= size)"); return false; @@ -7575,11 +7739,11 @@ namespace exprtk typedef string_base_node* strbase_ptr_t; range_data_type() - : range(0), - data (0), - size (0), - type_size(0), - str_node (0) + : range(0) + , data (0) + , size (0) + , type_size(0) + , str_node (0) {} range_t* range; @@ -7597,10 +7761,9 @@ namespace exprtk public: typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; - virtual ~vector_interface() - {} + virtual ~vector_interface() {} virtual std::size_t size () const = 0; @@ -7616,59 +7779,60 @@ namespace exprtk }; template - class vector_node : public expression_node , - public vector_interface + class vector_node exprtk_final + : public expression_node + , public vector_interface { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_holder vector_holder_t; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; explicit vector_node(vector_holder_t* vh) - : vector_holder_(vh), - vds_((*vector_holder_).size(),(*vector_holder_)[0]) + : vector_holder_(vh) + , vds_((*vector_holder_).size(),(*vector_holder_)[0]) { vector_holder_->set_ref(&vds_.ref()); } vector_node(const vds_t& vds, vector_holder_t* vh) - : vector_holder_(vh), - vds_(vds) + : vector_holder_(vh) + , vds_(vds) {} - inline T value() const + inline T value() const exprtk_override { return vds().data()[0]; } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return const_cast(this); } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return this; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vector; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -7685,7 +7849,8 @@ namespace exprtk }; template - class vector_elem_node : public expression_node, + class vector_elem_node exprtk_final + : public expression_node, public ivariable { public: @@ -7696,28 +7861,28 @@ namespace exprtk typedef std::pair branch_t; vector_elem_node(expression_ptr index, vector_holder_ptr vec_holder) - : vec_holder_(vec_holder), - vector_base_((*vec_holder)[0]) + : vec_holder_(vec_holder) + , vector_base_((*vec_holder)[0]) { construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecelem; } @@ -7727,12 +7892,12 @@ namespace exprtk return (*vec_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7745,7 +7910,8 @@ namespace exprtk }; template - class rebasevector_elem_node : public expression_node, + class rebasevector_elem_node exprtk_final + : public expression_node, public ivariable { public: @@ -7757,29 +7923,29 @@ namespace exprtk typedef std::pair branch_t; rebasevector_elem_node(expression_ptr index, vector_holder_ptr vec_holder) - : vector_holder_(vec_holder), - vds_((*vector_holder_).size(),(*vector_holder_)[0]) + : vector_holder_(vec_holder) + , vds_((*vector_holder_).size(),(*vector_holder_)[0]) { vector_holder_->set_ref(&vds_.ref()); construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbvecelem; } @@ -7789,12 +7955,12 @@ namespace exprtk return (*vector_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7807,7 +7973,8 @@ namespace exprtk }; template - class rebasevector_celem_node : public expression_node, + class rebasevector_celem_node exprtk_final + : public expression_node, public ivariable { public: @@ -7818,29 +7985,29 @@ namespace exprtk typedef vec_data_store vds_t; rebasevector_celem_node(const std::size_t index, vector_holder_ptr vec_holder) - : index_(index), - vector_holder_(vec_holder), - vds_((*vector_holder_).size(),(*vector_holder_)[0]) + : index_(index) + , vector_holder_(vec_holder) + , vds_((*vector_holder_).size(),(*vector_holder_)[0]) { vector_holder_->set_ref(&vds_.ref()); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + index_); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + index_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + index_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbveccelem; } @@ -7858,7 +8025,7 @@ namespace exprtk }; template - class vector_assignment_node : public expression_node + class vector_assignment_node exprtk_final : public expression_node { public: @@ -7868,13 +8035,13 @@ namespace exprtk const std::size_t& size, const std::vector& initialiser_list, const bool single_value_initialse) - : vector_base_(vector_base), - initialiser_list_(initialiser_list), - size_(size), - single_value_initialse_(single_value_initialse) + : vector_base_(vector_base) + , initialiser_list_(initialiser_list) + , size_(size) + , single_value_initialse_(single_value_initialse) {} - inline T value() const + inline T value() const exprtk_override { if (single_value_initialse_) { @@ -7885,16 +8052,16 @@ namespace exprtk } else { - std::size_t il_size = initialiser_list_.size(); + const std::size_t initialiser_list_size = initialiser_list_.size(); - for (std::size_t i = 0; i < il_size; ++i) + for (std::size_t i = 0; i < initialiser_list_size; ++i) { *(vector_base_ + i) = initialiser_list_[i]->value(); } - if (il_size < size_) + if (initialiser_list_size < size_) { - for (std::size_t i = il_size; i < size_; ++i) + for (std::size_t i = initialiser_list_size; i < size_; ++i) { *(vector_base_ + i) = T(0); } @@ -7904,24 +8071,25 @@ namespace exprtk return *(vector_base_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecdefass; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(initialiser_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(initialiser_list_); } private: - vector_assignment_node& operator=(const vector_assignment_node&); + vector_assignment_node(const vector_assignment_node&) exprtk_delete; + vector_assignment_node& operator=(const vector_assignment_node&) exprtk_delete; mutable T* vector_base_; std::vector initialiser_list_; @@ -7930,7 +8098,7 @@ namespace exprtk }; template - class swap_node : public expression_node + class swap_node exprtk_final : public expression_node { public: @@ -7938,17 +8106,17 @@ namespace exprtk typedef variable_node* variable_node_ptr; swap_node(variable_node_ptr var0, variable_node_ptr var1) - : var0_(var0), - var1_(var1) + : var0_(var0) + , var1_(var1) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -7960,26 +8128,26 @@ namespace exprtk }; template - class swap_generic_node : public binary_node + class swap_generic_node exprtk_final : public binary_node { public: typedef expression_node* expression_ptr; - typedef ivariable* ivariable_ptr; + typedef ivariable* ivariable_ptr; swap_generic_node(expression_ptr var0, expression_ptr var1) - : binary_node(details::e_swap, var0, var1), - var0_(dynamic_cast(var0)), - var1_(dynamic_cast(var1)) + : binary_node(details::e_swap, var0, var1) + , var0_(dynamic_cast(var0)) + , var1_(dynamic_cast(var1)) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -7991,22 +8159,23 @@ namespace exprtk }; template - class swap_vecvec_node : public binary_node , - public vector_interface + class swap_vecvec_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef expression_node* expression_ptr; + typedef vector_node * vector_node_ptr; + typedef vec_data_store vds_t; swap_vecvec_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_swap, branch0, branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - vec_size_ (0), - initialised_ (false) + : binary_node(details::e_swap, branch0, branch1) + , vec0_node_ptr_(0) + , vec1_node_ptr_(0) + , vec_size_ (0) + , initialised_ (false) { if (is_ivector_node(binary_node::branch_[0].first)) { @@ -8036,15 +8205,17 @@ namespace exprtk initialised_ = true; } + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { - assert(binary_node::branch_[0].first); - assert(binary_node::branch_[1].first); - if (initialised_) { + assert(binary_node::branch_[0].first); + assert(binary_node::branch_[1].first); + binary_node::branch_[0].first->value(); binary_node::branch_[1].first->value(); @@ -8062,32 +8233,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecswap; } - std::size_t size() const + std::size_t size() const exprtk_override { return vec_size_; } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -8103,13 +8274,14 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities template - class stringvar_node : public expression_node , + class stringvar_node exprtk_final + : public expression_node , public string_base_node, public range_interface { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; @@ -8131,7 +8303,7 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { rp_.n1_c.second = (*value_).size() - 1; rp_.cache.second = rp_.n1_c.second; @@ -8139,17 +8311,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return ref(); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8164,21 +8336,30 @@ namespace exprtk return (*value_); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvar; } + void rebase(std::string& s) + { + value_ = &s; + rp_.n0_c = std::make_pair(true,0); + rp_.n1_c = std::make_pair(true,value_->size() - 1); + rp_.cache.first = rp_.n0_c.second; + rp_.cache.second = rp_.n1_c.second; + } + private: std::string* value_; @@ -8189,19 +8370,20 @@ namespace exprtk std::string stringvar_node::null_value = std::string(""); template - class string_range_node : public expression_node , + class string_range_node exprtk_final + : public expression_node , public string_base_node, public range_interface { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; explicit string_range_node(std::string& v, const range_t& rp) - : value_(&v), - rp_(rp) + : value_(&v) + , rp_(rp) {} virtual ~string_range_node() @@ -8214,22 +8396,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline std::string str() const + inline std::string str() const exprtk_override { return (*value_); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8249,17 +8431,17 @@ namespace exprtk return (*value_); } - inline range_t& range_ref() + inline range_t& range_ref() exprtk_override { return rp_; } - inline const range_t& range_ref() const + inline const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarrng; } @@ -8274,17 +8456,18 @@ namespace exprtk std::string string_range_node::null_value = std::string(""); template - class const_string_range_node : public expression_node , + class const_string_range_node exprtk_final + : public expression_node , public string_base_node, public range_interface { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; explicit const_string_range_node(const std::string& v, const range_t& rp) - : value_(v), - rp_(rp) + : value_(v) + , rp_(rp) {} ~const_string_range_node() @@ -8292,22 +8475,22 @@ namespace exprtk rp_.free(); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } @@ -8317,51 +8500,52 @@ namespace exprtk return rp_; } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_cstringvarrng; } private: - const_string_range_node& operator=(const const_string_range_node&); + const_string_range_node(const const_string_range_node&) exprtk_delete; + const_string_range_node& operator=(const const_string_range_node&) exprtk_delete; const std::string value_; range_t rp_; }; template - class generic_string_range_node : public expression_node , + class generic_string_range_node exprtk_final + : public expression_node , public string_base_node, public range_interface { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef std::pair branch_t; - generic_string_range_node(expression_ptr str_branch, const range_t& brange) - : initialised_(false), - str_base_ptr_ (0), - str_range_ptr_(0), - base_range_(brange) + : initialised_(false) + , str_base_ptr_ (0) + , str_range_ptr_(0) + , base_range_(brange) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -8384,6 +8568,8 @@ namespace exprtk } initialised_ = (str_base_ptr_ && str_range_ptr_); + + assert(initialised_); } ~generic_string_range_node() @@ -8391,7 +8577,7 @@ namespace exprtk base_range_.free(); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8411,7 +8597,7 @@ namespace exprtk if ( range (str_r0, str_r1, base_str_size) && - base_range_( r0, r1, base_str_size) + base_range_( r0, r1, base_str_size - str_r0) ) { const std::size_t size = (r1 - r0) + 1; @@ -8426,42 +8612,42 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strgenrange; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -8469,37 +8655,38 @@ namespace exprtk private: bool initialised_; - branch_t branch_; - str_base_ptr str_base_ptr_; - irange_ptr str_range_ptr_; - mutable range_t base_range_; - mutable range_t range_; - mutable std::string value_; + branch_t branch_; + str_base_ptr str_base_ptr_; + irange_ptr str_range_ptr_; + mutable range_t base_range_; + mutable range_t range_; + mutable std::string value_; }; template - class string_concat_node : public binary_node , + class string_concat_node exprtk_final + : public binary_node , public string_base_node, public range_interface { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef typename range_interface::range_t range_t; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + typedef range_t* range_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; string_concat_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0) + : binary_node(opr, branch0, branch1) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -8537,9 +8724,11 @@ namespace exprtk str1_base_ptr_ && str0_range_ptr_ && str1_range_ptr_ ; + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8577,61 +8766,62 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strconcat; } private: - bool initialised_; - str_base_ptr str0_base_ptr_; - str_base_ptr str1_base_ptr_; - irange_ptr str0_range_ptr_; - irange_ptr str1_range_ptr_; + bool initialised_; + str_base_ptr str0_base_ptr_; + str_base_ptr str1_base_ptr_; + irange_ptr str0_range_ptr_; + irange_ptr str1_range_ptr_; mutable range_t range_; mutable std::string value_; }; template - class swap_string_node : public binary_node , + class swap_string_node exprtk_final + : public binary_node , public string_base_node, public range_interface { public: - typedef expression_node * expression_ptr; + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; swap_string_node(expression_ptr branch0, expression_ptr branch1) : binary_node(details::e_swap, branch0, branch1), @@ -8650,9 +8840,11 @@ namespace exprtk } initialised_ = (str0_node_ptr_ && str1_node_ptr_); + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8668,32 +8860,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } @@ -8706,25 +8898,25 @@ namespace exprtk }; template - class swap_genstrings_node : public binary_node + class swap_genstrings_node exprtk_final : public binary_node { public: + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; swap_genstrings_node(expression_ptr branch0, expression_ptr branch1) - : binary_node(details::e_default, branch0, branch1), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0), - initialised_(false) + : binary_node(details::e_default, branch0, branch1) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) + , initialised_(false) { if (is_generally_string_node(binary_node::branch_[0].first)) { @@ -8760,9 +8952,11 @@ namespace exprtk str1_base_ptr_ && str0_range_ptr_ && str1_range_ptr_ ; + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8845,15 +9039,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } private: - swap_genstrings_node(swap_genstrings_node&); - swap_genstrings_node& operator=(swap_genstrings_node&); + swap_genstrings_node(const swap_genstrings_node&) exprtk_delete; + swap_genstrings_node& operator=(const swap_genstrings_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -8863,7 +9057,7 @@ namespace exprtk }; template - class stringvar_size_node : public expression_node + class stringvar_size_node exprtk_final : public expression_node { public: @@ -8877,12 +9071,12 @@ namespace exprtk : value_(&v) {} - inline T value() const + inline T value() const exprtk_override { return T((*value_).size()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarsize; } @@ -8896,15 +9090,14 @@ namespace exprtk std::string stringvar_size_node::null_value = std::string(""); template - class string_size_node : public expression_node + class string_size_node exprtk_final : public expression_node { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; typedef std::pair branch_t; - explicit string_size_node(expression_ptr branch) : str_base_ptr_(0) { @@ -8919,7 +9112,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = std::numeric_limits::quiet_NaN(); @@ -8932,17 +9125,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringsize; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -8966,29 +9159,30 @@ namespace exprtk }; template - class assignment_string_node : public binary_node , + class assignment_string_node exprtk_final + : public binary_node , public string_base_node, public range_interface { public: - typedef expression_node * expression_ptr; + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; assignment_string_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_node_ptr_ (0), - str1_range_ptr_(0) + : binary_node(opr, branch0, branch1) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_node_ptr_ (0) + , str1_range_ptr_(0) { if (is_string_node(binary_node::branch_[0].first)) { @@ -9016,9 +9210,11 @@ namespace exprtk str1_base_ptr_ && str0_node_ptr_ && str1_range_ptr_ ; + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9045,32 +9241,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9085,31 +9281,32 @@ namespace exprtk }; template - class assignment_string_range_node : public binary_node , + class assignment_string_range_node exprtk_final + : public binary_node , public string_base_node, public range_interface { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; typedef string_range_node* str_rng_node_ptr; - typedef string_base_node * str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node * str_base_ptr; assignment_string_range_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_rng_node_ptr_ (0), - str0_range_ptr_ (0), - str1_range_ptr_ (0) + : binary_node(opr, branch0, branch1) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_rng_node_ptr_(0) + , str0_range_ptr_ (0) + , str1_range_ptr_ (0) { if (is_string_range_node(binary_node::branch_[0].first)) { @@ -9145,9 +9342,11 @@ namespace exprtk str0_rng_node_ptr_ && str0_range_ptr_ && str1_range_ptr_ ; + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9182,32 +9381,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_rng_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_rng_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9223,31 +9422,32 @@ namespace exprtk }; template - class conditional_string_node : public trinary_node , + class conditional_string_node exprtk_final + : public trinary_node , public string_base_node, public range_interface { public: + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; conditional_string_node(expression_ptr condition, expression_ptr consequent, expression_ptr alternative) - : trinary_node(details::e_default,consequent,alternative,condition), - initialised_(false), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0), - condition_ (condition), - consequent_ (consequent), - alternative_(alternative) + : trinary_node(details::e_default, consequent, alternative, condition) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) + , condition_ (condition ) + , consequent_ (consequent ) + , alternative_(alternative) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -9286,9 +9486,10 @@ namespace exprtk str0_range_ptr_ && str1_range_ptr_ ; + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9340,32 +9541,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strcondition; } @@ -9386,27 +9587,28 @@ namespace exprtk }; template - class cons_conditional_str_node : public binary_node , + class cons_conditional_str_node exprtk_final + : public binary_node , public string_base_node, public range_interface { public: + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; cons_conditional_str_node(expression_ptr condition, expression_ptr consequent) - : binary_node(details::e_default, consequent, condition), - initialised_(false), - str0_base_ptr_ (0), - str0_range_ptr_(0), - condition_ (condition), - consequent_(consequent) + : binary_node(details::e_default, consequent, condition) + , initialised_(false) + , str0_base_ptr_ (0) + , str0_range_ptr_(0) + , condition_ (condition ) + , consequent_(consequent) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -9428,9 +9630,11 @@ namespace exprtk } initialised_ = str0_base_ptr_ && str0_range_ptr_ ; + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9488,7 +9692,7 @@ namespace exprtk return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strccondition; } @@ -9506,26 +9710,27 @@ namespace exprtk }; template - class str_vararg_node : public expression_node , - public string_base_node, - public range_interface + class str_vararg_node exprtk_final + : public expression_node , + public string_base_node, + public range_interface { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; typedef std::pair branch_t; template class Sequence> explicit str_vararg_node(const Sequence& arg_list) - : initialised_(false), - str_base_ptr_ (0), - str_range_ptr_(0) + : initialised_(false) + , str_base_ptr_ (0) + , str_range_ptr_(0) { construct_branch_pair(final_node_, const_cast(arg_list.back())); @@ -9567,7 +9772,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) { @@ -9579,43 +9784,43 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str_range_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str_range_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { - expression_node::ndb_t::collect(final_node_, node_delete_list); - expression_node::ndb_t::collect(arg_list_ , node_delete_list); + expression_node::ndb_t::collect(final_node_ , node_delete_list); + expression_node::ndb_t::collect(arg_list_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return std::max( expression_node::ndb_t::compute_node_depth(final_node_), @@ -9633,14 +9838,14 @@ namespace exprtk #endif template - inline T axn(T a, T x) + inline T axn(const T a, const T x) { // a*x^n return a * exprtk::details::numeric::fast_exp::result(x); } template - inline T axnb(T a, T x, T b) + inline T axnb(const T a, const T x, const T b) { // a*x^n+b return a * exprtk::details::numeric::fast_exp::result(x) + b; @@ -9652,12 +9857,12 @@ namespace exprtk typedef typename details::functor_t::Type Type; typedef typename details::functor_t functor_t; typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; }; - #define define_sfop3(NN,OP0,OP1) \ + #define define_sfop3(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9721,7 +9926,7 @@ namespace exprtk define_sfop3(46,x * numeric::cos(y) - z ,"") define_sfop3(47,details::is_true(x) ? y : z,"") - #define define_sfop4(NN,OP0,OP1) \ + #define define_sfop4(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9857,7 +10062,7 @@ namespace exprtk #undef define_sfop4 template - class sf3_node : public trinary_node + class sf3_node exprtk_final : public trinary_node { public: @@ -9870,7 +10075,7 @@ namespace exprtk : trinary_node(opr, branch0, branch1, branch2) {} - inline T value() const + inline T value() const exprtk_override { assert(trinary_node::branch_[0].first); assert(trinary_node::branch_[1].first); @@ -9885,7 +10090,7 @@ namespace exprtk }; template - class sf4_node : public quaternary_node + class sf4_node exprtk_final : public quaternary_node { public: @@ -9899,7 +10104,7 @@ namespace exprtk : quaternary_node(opr, branch0, branch1, branch2, branch3) {} - inline T value() const + inline T value() const exprtk_override { assert(quaternary_node::branch_[0].first); assert(quaternary_node::branch_[1].first); @@ -9916,32 +10121,32 @@ namespace exprtk }; template - class sf3_var_node : public expression_node + class sf3_var_node exprtk_final : public expression_node { public: typedef expression_node* expression_ptr; sf3_var_node(const T& v0, const T& v1, const T& v2) - : v0_(v0), - v1_(v1), - v2_(v2) + : v0_(v0) + , v1_(v1) + , v2_(v2) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf3_var_node(sf3_var_node&); - sf3_var_node& operator=(sf3_var_node&); + sf3_var_node(const sf3_var_node&) exprtk_delete; + sf3_var_node& operator=(const sf3_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -9949,33 +10154,33 @@ namespace exprtk }; template - class sf4_var_node : public expression_node + class sf4_var_node exprtk_final : public expression_node { public: typedef expression_node* expression_ptr; sf4_var_node(const T& v0, const T& v1, const T& v2, const T& v3) - : v0_(v0), - v1_(v1), - v2_(v2), - v3_(v3) + : v0_(v0) + , v1_(v1) + , v2_(v2) + , v3_(v3) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_, v3_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf4_var_node(sf4_var_node&); - sf4_var_node& operator=(sf4_var_node&); + sf4_var_node(const sf4_var_node&) exprtk_delete; + sf4_var_node& operator=(const sf4_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -9984,7 +10189,7 @@ namespace exprtk }; template - class vararg_node : public expression_node + class vararg_node exprtk_final : public expression_node { public: @@ -10011,22 +10216,22 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { return VarArgFunction::process(arg_list_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -10037,7 +10242,7 @@ namespace exprtk }; template - class vararg_varnode : public expression_node + class vararg_varnode exprtk_final : public expression_node { public: @@ -10064,7 +10269,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) return VarArgFunction::process(arg_list_); @@ -10072,7 +10277,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } @@ -10083,7 +10288,7 @@ namespace exprtk }; template - class vectorize_node : public expression_node + class vectorize_node exprtk_final : public expression_node { public: @@ -10103,7 +10308,7 @@ namespace exprtk ivec_ptr_ = 0; } - inline T value() const + inline T value() const exprtk_override { if (ivec_ptr_) { @@ -10117,17 +10322,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecfunc; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(v_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(v_); } @@ -10139,7 +10344,7 @@ namespace exprtk }; template - class assignment_node : public binary_node + class assignment_node exprtk_final : public binary_node { public: @@ -10148,8 +10353,8 @@ namespace exprtk assignment_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - var_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , var_node_ptr_(0) { if (is_variable_node(binary_node::branch_[0].first)) { @@ -10157,7 +10362,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10179,7 +10384,7 @@ namespace exprtk }; template - class assignment_vec_elem_node : public binary_node + class assignment_vec_elem_node exprtk_final : public binary_node { public: @@ -10188,8 +10393,8 @@ namespace exprtk assignment_vec_elem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , vec_node_ptr_(0) { if (is_vector_elem_node(binary_node::branch_[0].first)) { @@ -10197,7 +10402,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10219,7 +10424,7 @@ namespace exprtk }; template - class assignment_rebasevec_elem_node : public binary_node + class assignment_rebasevec_elem_node exprtk_final : public binary_node { public: @@ -10228,8 +10433,8 @@ namespace exprtk assignment_rebasevec_elem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - rbvec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , rbvec_node_ptr_(0) { if (is_rebasevector_elem_node(binary_node::branch_[0].first)) { @@ -10237,7 +10442,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10259,7 +10464,7 @@ namespace exprtk }; template - class assignment_rebasevec_celem_node : public binary_node + class assignment_rebasevec_celem_node exprtk_final : public binary_node { public: @@ -10268,8 +10473,8 @@ namespace exprtk assignment_rebasevec_celem_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - rbvec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , rbvec_node_ptr_(0) { if (is_rebasevector_celem_node(binary_node::branch_[0].first)) { @@ -10277,7 +10482,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10299,20 +10504,21 @@ namespace exprtk }; template - class assignment_vec_node : public binary_node , - public vector_interface + class assignment_vec_node exprtk_final + : public binary_node + , public vector_interface { public: typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vector_node* vector_node_ptr; + typedef vec_data_store vds_t; assignment_vec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , vec_node_ptr_(0) { if (is_vector_node(binary_node::branch_[0].first)) { @@ -10321,7 +10527,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10381,32 +10587,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10418,23 +10624,24 @@ namespace exprtk }; template - class assignment_vecvec_node : public binary_node , - public vector_interface + class assignment_vecvec_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; assignment_vecvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - initialised_(false), - src_is_ivec_(false) + : binary_node(opr, branch0, branch1) + , vec0_node_ptr_(0) + , vec1_node_ptr_(0) + , initialised_(false) + , src_is_ivec_(false) { if (is_vector_node(binary_node::branch_[0].first)) { @@ -10466,9 +10673,11 @@ namespace exprtk } initialised_ = (vec0_node_ptr_ && vec1_node_ptr_); + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -10533,32 +10742,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10573,7 +10782,7 @@ namespace exprtk }; template - class assignment_op_node : public binary_node + class assignment_op_node exprtk_final : public binary_node { public: @@ -10582,8 +10791,8 @@ namespace exprtk assignment_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - var_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , var_node_ptr_(0) { if (is_variable_node(binary_node::branch_[0].first)) { @@ -10591,7 +10800,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10612,7 +10821,7 @@ namespace exprtk }; template - class assignment_vec_elem_op_node : public binary_node + class assignment_vec_elem_op_node exprtk_final : public binary_node { public: @@ -10621,8 +10830,8 @@ namespace exprtk assignment_vec_elem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , vec_node_ptr_(0) { if (is_vector_elem_node(binary_node::branch_[0].first)) { @@ -10630,7 +10839,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10651,7 +10860,7 @@ namespace exprtk }; template - class assignment_rebasevec_elem_op_node : public binary_node + class assignment_rebasevec_elem_op_node exprtk_final : public binary_node { public: @@ -10660,8 +10869,8 @@ namespace exprtk assignment_rebasevec_elem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - rbvec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , rbvec_node_ptr_(0) { if (is_rebasevector_elem_node(binary_node::branch_[0].first)) { @@ -10669,7 +10878,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10690,7 +10899,7 @@ namespace exprtk }; template - class assignment_rebasevec_celem_op_node : public binary_node + class assignment_rebasevec_celem_op_node exprtk_final : public binary_node { public: @@ -10699,8 +10908,8 @@ namespace exprtk assignment_rebasevec_celem_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - rbvec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , rbvec_node_ptr_(0) { if (is_rebasevector_celem_node(binary_node::branch_[0].first)) { @@ -10708,7 +10917,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10729,20 +10938,21 @@ namespace exprtk }; template - class assignment_vec_op_node : public binary_node , - public vector_interface + class assignment_vec_op_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; assignment_vec_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec_node_ptr_(0) + : binary_node(opr, branch0, branch1) + , vec_node_ptr_(0) { if (is_vector_node(binary_node::branch_[0].first)) { @@ -10751,7 +10961,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10802,7 +11012,6 @@ namespace exprtk } exprtk_disable_fallthrough_end - #undef exprtk_loop #undef case_stmt @@ -10812,37 +11021,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -10854,22 +11063,23 @@ namespace exprtk }; template - class assignment_vecvec_op_node : public binary_node , - public vector_interface + class assignment_vecvec_op_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; assignment_vecvec_op_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - initialised_(false) + : binary_node(opr, branch0, branch1) + , vec0_node_ptr_(0) + , vec1_node_ptr_(0) + , initialised_(false) { if (is_vector_node(binary_node::branch_[0].first)) { @@ -10896,9 +11106,11 @@ namespace exprtk } initialised_ = (vec0_node_ptr_ && vec1_node_ptr_); + + assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -10964,37 +11176,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -11008,25 +11220,26 @@ namespace exprtk }; template - class vec_binop_vecvec_node : public binary_node , - public vector_interface + class vec_binop_vecvec_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; typedef vector_holder* vector_holder_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; vec_binop_vecvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec0_node_ptr_(0), - vec1_node_ptr_(0), - temp_ (0), - temp_vec_node_(0), - initialised_(false) + : binary_node(opr, branch0, branch1) + , vec0_node_ptr_(0) + , vec1_node_ptr_(0) + , temp_ (0) + , temp_vec_node_(0) + , initialised_(false) { bool v0_is_ivec = false; bool v1_is_ivec = false; @@ -11074,10 +11287,12 @@ namespace exprtk vds_ = vds_t(std::min(vec0.size(),vec1.size())); temp_ = new vector_holder(vds().data(),vds().size()); - temp_vec_node_ = new vector_node (vds(),temp_); + temp_vec_node_ = new vector_node (vds(),temp_); initialised_ = true; } + + assert(initialised_); } ~vec_binop_vecvec_node() @@ -11086,7 +11301,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11154,32 +11369,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds_.size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11195,23 +11410,24 @@ namespace exprtk }; template - class vec_binop_vecval_node : public binary_node , - public vector_interface + class vec_binop_vecval_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; typedef vector_holder* vector_holder_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; vec_binop_vecval_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec0_node_ptr_(0), - temp_ (0), - temp_vec_node_(0) + : binary_node(opr, branch0, branch1) + , vec0_node_ptr_(0) + , temp_ (0) + , temp_vec_node_(0) { bool v0_is_ivec = false; @@ -11238,7 +11454,7 @@ namespace exprtk vds() = vds_t(vec0_node_ptr_->size()); temp_ = new vector_holder(vds()); - temp_vec_node_ = new vector_node (vds(),temp_); + temp_vec_node_ = new vector_node (vds(),temp_); } } @@ -11248,7 +11464,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec0_node_ptr_) { @@ -11314,32 +11530,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11353,23 +11569,24 @@ namespace exprtk }; template - class vec_binop_valvec_node : public binary_node , - public vector_interface + class vec_binop_valvec_node exprtk_final + : public binary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; typedef vector_holder* vector_holder_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; vec_binop_valvec_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - vec1_node_ptr_(0), - temp_ (0), - temp_vec_node_(0) + : binary_node(opr, branch0, branch1) + , vec1_node_ptr_(0) + , temp_ (0) + , temp_vec_node_(0) { bool v1_is_ivec = false; @@ -11396,7 +11613,7 @@ namespace exprtk vds() = vds_t(vec1_node_ptr_->size()); temp_ = new vector_holder(vds()); - temp_vec_node_ = new vector_node (vds(),temp_); + temp_vec_node_ = new vector_node (vds(),temp_); } } @@ -11406,7 +11623,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec1_node_ptr_) { @@ -11472,32 +11689,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11511,21 +11728,22 @@ namespace exprtk }; template - class unary_vector_node : public unary_node , - public vector_interface + class unary_vector_node exprtk_final + : public unary_node + , public vector_interface { public: - typedef expression_node* expression_ptr; - typedef vector_node* vector_node_ptr; + typedef expression_node* expression_ptr; + typedef vector_node* vector_node_ptr; typedef vector_holder* vector_holder_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; unary_vector_node(const operator_type& opr, expression_ptr branch0) - : unary_node(opr, branch0), - vec0_node_ptr_(0), - temp_ (0), - temp_vec_node_(0) + : unary_node(opr, branch0) + , vec0_node_ptr_(0) + , temp_ (0) + , temp_vec_node_(0) { bool vec0_is_ivec = false; @@ -11552,7 +11770,7 @@ namespace exprtk vds_ = vds_t(vec0_node_ptr_->size()); temp_ = new vector_holder(vds()); - temp_vec_node_ = new vector_node (vds(),temp_); + temp_vec_node_ = new vector_node (vds(),temp_); } } @@ -11562,7 +11780,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { assert(unary_node::branch_.first); @@ -11626,32 +11844,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecunaryop; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11665,7 +11883,167 @@ namespace exprtk }; template - class scand_node : public binary_node + class conditional_vector_node exprtk_final + : public expression_node + , public vector_interface + { + public: + + typedef expression_node * expression_ptr; + typedef vector_interface* vec_interface_ptr; + typedef vector_node * vector_node_ptr; + typedef vector_holder * vector_holder_ptr; + typedef vec_data_store vds_t; + typedef std::pair branch_t; + + conditional_vector_node(expression_ptr condition, + expression_ptr consequent, + expression_ptr alternative) + : consequent_node_ptr_ (0) + , alternative_node_ptr_(0) + , temp_vec_node_ (0) + , temp_ (0) + , vec_size_ (0) + , initialised_ (false) + { + construct_branch_pair(condition_ , condition ); + construct_branch_pair(consequent_ , consequent ); + construct_branch_pair(alternative_, alternative); + + if (details::is_ivector_node(consequent_.first)) + { + vec_interface_ptr ivec_ptr = dynamic_cast(consequent_.first); + + if (0 != ivec_ptr) + { + consequent_node_ptr_ = ivec_ptr->vec(); + } + } + + if (details::is_ivector_node(alternative_.first)) + { + vec_interface_ptr ivec_ptr = dynamic_cast(alternative_.first); + + if (0 != ivec_ptr) + { + alternative_node_ptr_ = ivec_ptr->vec(); + } + } + + if (consequent_node_ptr_ && alternative_node_ptr_) + { + vec_size_ = std::min(consequent_node_ptr_ ->vds().size(), + alternative_node_ptr_->vds().size()); + + vds_ = vds_t(vec_size_); + temp_ = new vector_holder(vds_); + temp_vec_node_ = new vector_node (vds(),temp_); + + initialised_ = true; + } + + assert(initialised_ && (vec_size_ > 0)); + } + + ~conditional_vector_node() + { + delete temp_; + delete temp_vec_node_; + } + + inline T value() const exprtk_override + { + if (initialised_) + { + assert(condition_ .first); + assert(consequent_ .first); + assert(alternative_.first); + + T result = T(0); + T* source_vector = 0; + T* result_vector = vds().data(); + + if (is_true(condition_)) + { + result = consequent_.first->value(); + source_vector = consequent_node_ptr_->vds().data(); + } + else + { + result = alternative_.first->value(); + source_vector = alternative_node_ptr_->vds().data(); + } + + for (std::size_t i = 0; i < vec_size_; ++i) + { + result_vector[i] = source_vector[i]; + } + + return result; + } + + return std::numeric_limits::quiet_NaN(); + } + + vector_node_ptr vec() const exprtk_override + { + return temp_vec_node_; + } + + vector_node_ptr vec() exprtk_override + { + return temp_vec_node_; + } + + inline typename expression_node::node_type type() const exprtk_override + { + return expression_node::e_vecondition; + } + + std::size_t size() const exprtk_override + { + return vec_size_; + } + + vds_t& vds() exprtk_override + { + return vds_; + } + + const vds_t& vds() const exprtk_override + { + return vds_; + } + + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override + { + expression_node::ndb_t::collect(condition_ , node_delete_list); + expression_node::ndb_t::collect(consequent_ , node_delete_list); + expression_node::ndb_t::collect(alternative_ , node_delete_list); + } + + std::size_t node_depth() const exprtk_override + { + return expression_node::ndb_t::compute_node_depth + (condition_, consequent_, alternative_); + } + + private: + + branch_t condition_; + branch_t consequent_; + branch_t alternative_; + vector_node_ptr consequent_node_ptr_; + vector_node_ptr alternative_node_ptr_; + vector_node_ptr temp_vec_node_; + vector_holder_ptr temp_; + vds_t vds_; + std::size_t vec_size_; + bool initialised_; + }; + + template + class scand_node exprtk_final : public binary_node { public: @@ -11677,7 +12055,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11692,7 +12070,7 @@ namespace exprtk }; template - class scor_node : public binary_node + class scor_node exprtk_final : public binary_node { public: @@ -11704,7 +12082,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11719,7 +12097,7 @@ namespace exprtk }; template - class function_N_node : public expression_node + class function_N_node exprtk_final : public expression_node { public: @@ -11729,8 +12107,8 @@ namespace exprtk typedef IFunction ifunction; explicit function_N_node(ifunction* func) - : function_((N == func->param_count) ? func : reinterpret_cast(0)), - parameter_count_(func->param_count) + : function_((N == func->param_count) ? func : reinterpret_cast(0)) + , parameter_count_(func->param_count) {} template @@ -11764,7 +12142,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { // Needed for incompetent and broken msvc compiler versions #ifdef _MSC_VER @@ -11784,6 +12162,21 @@ namespace exprtk #endif } + inline typename expression_node::node_type type() const exprtk_override + { + return expression_node::e_function; + } + + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override + { + expression_node::ndb_t::template collect(branch_, node_delete_list); + } + + std::size_t node_depth() const exprtk_override + { + return expression_node::ndb_t::template compute_node_depth(branch_); + } + template struct evaluate_branches { @@ -11872,119 +12265,119 @@ namespace exprtk struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[18]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15], v[16], v[17]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[17]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15], v[16]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[16]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14], v[15]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[15]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13], v[14]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[14]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[13]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[13]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[12]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[11]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[10]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[9]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[8]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[7]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5],v[6]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5], v[6]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[6]) - { return f(v[0],v[1],v[2],v[3],v[4],v[5]); } + { return f(v[0], v[1], v[2], v[3], v[4], v[5]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[5]) - { return f(v[0],v[1],v[2],v[3],v[4]); } + { return f(v[0], v[1], v[2], v[3], v[4]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[4]) - { return f(v[0],v[1],v[2],v[3]); } + { return f(v[0], v[1], v[2], v[3]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[3]) - { return f(v[0],v[1],v[2]); } + { return f(v[0], v[1], v[2]); } }; template struct invoke { static inline T_ execute(ifunction& f, T_ (&v)[2]) - { return f(v[0],v[1]); } + { return f(v[0], v[1]); } }; template @@ -11994,21 +12387,6 @@ namespace exprtk { return f(v[0]); } }; - inline typename expression_node::node_type type() const - { - return expression_node::e_function; - } - - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::template collect(branch_, node_delete_list); - } - - std::size_t node_depth() const - { - return expression_node::ndb_t::template compute_node_depth(branch_); - } - private: ifunction* function_; @@ -12017,7 +12395,7 @@ namespace exprtk }; template - class function_N_node : public expression_node + class function_N_node exprtk_final : public expression_node { public: @@ -12033,7 +12411,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) return (*function_)(); @@ -12041,7 +12419,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_function; } @@ -12052,7 +12430,7 @@ namespace exprtk }; template - class vararg_function_node : public expression_node + class vararg_function_node exprtk_final : public expression_node { public: @@ -12060,8 +12438,8 @@ namespace exprtk vararg_function_node(VarArgFunction* func, const std::vector& arg_list) - : function_(func), - arg_list_(arg_list) + : function_(func) + , arg_list_(arg_list) { value_list_.resize(arg_list.size(),std::numeric_limits::quiet_NaN()); } @@ -12071,7 +12449,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12082,12 +12460,12 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vafunction; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { for (std::size_t i = 0; i < arg_list_.size(); ++i) { @@ -12098,7 +12476,7 @@ namespace exprtk } } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -12123,36 +12501,37 @@ namespace exprtk { public: - typedef type_store type_store_t; - typedef expression_node* expression_ptr; - typedef variable_node variable_node_t; - typedef vector_node vector_node_t; - typedef variable_node_t* variable_node_ptr_t; - typedef vector_node_t* vector_node_ptr_t; - typedef range_interface range_interface_t; - typedef range_data_type range_data_type_t; - typedef range_pack range_t; - typedef std::pair branch_t; - typedef std::pair void_t; - typedef std::vector tmp_vs_t; - typedef std::vector typestore_list_t; - typedef std::vector range_list_t; + typedef type_store type_store_t; + typedef expression_node* expression_ptr; + typedef variable_node variable_node_t; + typedef vector_node vector_node_t; + typedef variable_node_t* variable_node_ptr_t; + typedef vector_node_t* vector_node_ptr_t; + typedef range_interface range_interface_t; + typedef range_data_type range_data_type_t; + typedef typename range_interface::range_t range_t; + + typedef std::pair branch_t; + typedef std::pair void_t; + + typedef std::vector tmp_vs_t; + typedef std::vector typestore_list_t; + typedef std::vector range_list_t; explicit generic_function_node(const std::vector& arg_list, - GenericFunction* func = (GenericFunction*)(0)) - : function_(func), - arg_list_(arg_list) + GenericFunction* func = reinterpret_cast(0)) + : function_(func) + , arg_list_(arg_list) {} - virtual ~generic_function_node() - {} + virtual ~generic_function_node() {} - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -12162,7 +12541,7 @@ namespace exprtk expr_as_vec1_store_.resize(arg_list_.size(),T(0) ); typestore_list_ .resize(arg_list_.size(),type_store_t() ); range_list_ .resize(arg_list_.size(),range_data_type_t()); - branch_ .resize(arg_list_.size(),branch_t((expression_ptr)0,false)); + branch_ .resize(arg_list_.size(),branch_t(reinterpret_cast(0),false)); for (std::size_t i = 0; i < arg_list_.size(); ++i) { @@ -12248,7 +12627,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12263,7 +12642,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_genfunction; } @@ -12327,7 +12706,7 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; string_function_node(StringFunction* func, const std::vector& arg_list) @@ -12344,7 +12723,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12368,32 +12747,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } - std::string str() const + std::string str() const exprtk_override { return ret_string_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &ret_string_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ret_string_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } @@ -12411,16 +12790,16 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename gen_function_t::range_t range_t; multimode_genfunction_node(GenericFunction* func, const std::size_t& param_seq_index, const std::vector& arg_list) - : gen_function_t(arg_list,func), - param_seq_index_(param_seq_index) + : gen_function_t(arg_list,func) + , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12439,7 +12818,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_genfunction; } @@ -12451,21 +12830,21 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities template - class multimode_strfunction_node : public string_function_node + class multimode_strfunction_node exprtk_final : public string_function_node { public: typedef string_function_node str_function_t; - typedef range_pack range_t; + typedef typename str_function_t::range_t range_t; multimode_strfunction_node(StringFunction* func, const std::size_t& param_seq_index, const std::vector& arg_list) - : str_function_t(func,arg_list), - param_seq_index_(param_seq_index) + : str_function_t(func,arg_list) + , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (str_function_t::function_) { @@ -12490,7 +12869,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } @@ -12509,8 +12888,7 @@ namespace exprtk { public: - virtual ~null_igenfunc() - {} + virtual ~null_igenfunc() {} typedef type_store generic_type; typedef typename generic_type::parameter_list parameter_list_t; @@ -12523,22 +12901,22 @@ namespace exprtk #ifndef exprtk_disable_return_statement template - class return_node : public generic_function_node > + class return_node exprtk_final : public generic_function_node > { public: - typedef null_igenfunc igeneric_function_t; + typedef results_context results_context_t; + typedef null_igenfunc igeneric_function_t; typedef igeneric_function_t* igeneric_function_ptr; typedef generic_function_node gen_function_t; - typedef results_context results_context_t; return_node(const std::vector& arg_list, results_context_t& rc) - : gen_function_t (arg_list), - results_context_(&rc) + : gen_function_t (arg_list) + , results_context_(&rc) {} - inline T value() const + inline T value() const exprtk_override { if ( (0 != results_context_) && @@ -12556,7 +12934,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_return; } @@ -12567,7 +12945,7 @@ namespace exprtk }; template - class return_envelope_node : public expression_node + class return_envelope_node exprtk_final : public expression_node { public: @@ -12576,13 +12954,13 @@ namespace exprtk typedef std::pair branch_t; return_envelope_node(expression_ptr body, results_context_t& rc) - : results_context_(&rc ), - return_invoked_ (false) + : results_context_(&rc ) + , return_invoked_ (false) { construct_branch_pair(body_, body); } - inline T value() const + inline T value() const exprtk_override { assert(body_.first); @@ -12600,7 +12978,7 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_retenv; } @@ -12610,12 +12988,12 @@ namespace exprtk return &return_invoked_; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(body_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(body_); } @@ -12698,11 +13076,11 @@ namespace exprtk { typedef typename details::functor_t::Type Type; typedef typename details::functor_t::RefType RefType; - typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename details::functor_t functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; }; template @@ -13858,8 +14236,7 @@ namespace exprtk { public: - virtual ~vov_base_node() - {} + virtual ~vov_base_node() {} inline virtual operator_type operation() const { @@ -13876,8 +14253,7 @@ namespace exprtk { public: - virtual ~cov_base_node() - {} + virtual ~cov_base_node() {} inline virtual operator_type operation() const { @@ -13894,8 +14270,7 @@ namespace exprtk { public: - virtual ~voc_base_node() - {} + virtual ~voc_base_node() {} inline virtual operator_type operation() const { @@ -13912,8 +14287,7 @@ namespace exprtk { public: - virtual ~vob_base_node() - {} + virtual ~vob_base_node() {} virtual const T& v() const = 0; }; @@ -13923,8 +14297,7 @@ namespace exprtk { public: - virtual ~bov_base_node() - {} + virtual ~bov_base_node() {} virtual const T& v() const = 0; }; @@ -13934,8 +14307,7 @@ namespace exprtk { public: - virtual ~cob_base_node() - {} + virtual ~cob_base_node() {} inline virtual operator_type operation() const { @@ -13954,8 +14326,7 @@ namespace exprtk { public: - virtual ~boc_base_node() - {} + virtual ~boc_base_node() {} inline virtual operator_type operation() const { @@ -13974,8 +14345,7 @@ namespace exprtk { public: - virtual ~uv_base_node() - {} + virtual ~uv_base_node() {} inline virtual operator_type operation() const { @@ -13990,8 +14360,7 @@ namespace exprtk { public: - virtual ~sos_base_node() - {} + virtual ~sos_base_node() {} inline virtual operator_type operation() const { @@ -14004,8 +14373,7 @@ namespace exprtk { public: - virtual ~sosos_base_node() - {} + virtual ~sosos_base_node() {} inline virtual operator_type operation() const { @@ -14018,8 +14386,7 @@ namespace exprtk { public: - virtual ~T0oT1oT2_base_node() - {} + virtual ~T0oT1oT2_base_node() {} virtual std::string type_id() const = 0; }; @@ -14029,14 +14396,13 @@ namespace exprtk { public: - virtual ~T0oT1oT2oT3_base_node() - {} + virtual ~T0oT1oT2oT3_base_node() {} virtual std::string type_id() const = 0; }; template - class unary_variable_node : public uv_base_node + class unary_variable_node exprtk_final : public uv_base_node { public: @@ -14047,70 +14413,64 @@ namespace exprtk : v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } private: - unary_variable_node(unary_variable_node&); - unary_variable_node& operator=(unary_variable_node&); + unary_variable_node(const unary_variable_node&) exprtk_delete; + unary_variable_node& operator=(const unary_variable_node&) exprtk_delete; const T& v_; }; template - class uvouv_node : public expression_node + class uvouv_node exprtk_final : public expression_node { public: // UOpr1(v0) Op UOpr2(v1) - - typedef expression_node* expression_ptr; typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; - typedef typename functor_t::ufunc_t ufunc_t; + typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::ufunc_t ufunc_t; + typedef expression_node* expression_ptr; explicit uvouv_node(const T& var0,const T& var1, ufunc_t uf0, ufunc_t uf1, bfunc_t bf) - : v0_(var0), - v1_(var1), - u0_(uf0 ), - u1_(uf1 ), - f_ (bf ) + : v0_(var0) + , v1_(var1) + , u0_(uf0 ) + , u1_(uf1 ) + , f_ (bf ) {} - inline T value() const + inline T value() const exprtk_override { return f_(u0_(v0_),u1_(v1_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_uvouv; } - inline operator_type operation() const - { - return details::e_default; - } - inline const T& v0() { return v0_; @@ -14138,8 +14498,8 @@ namespace exprtk private: - uvouv_node(uvouv_node&); - uvouv_node& operator=(uvouv_node&); + uvouv_node(const uvouv_node&) exprtk_delete; + uvouv_node& operator=(const uvouv_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -14149,35 +14509,35 @@ namespace exprtk }; template - class unary_branch_node : public expression_node + class unary_branch_node exprtk_final : public expression_node { public: - typedef expression_node* expression_ptr; + typedef Operation operation_t; + typedef expression_node* expression_ptr; typedef std::pair branch_t; - typedef Operation operation_t; explicit unary_branch_node(expression_ptr branch) { construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { return Operation::process(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() { return Operation::operation(); } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -14187,20 +14547,20 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - unary_branch_node(unary_branch_node&); - unary_branch_node& operator=(unary_branch_node&); + unary_branch_node(const unary_branch_node&) exprtk_delete; + unary_branch_node& operator=(const unary_branch_node&) exprtk_delete; branch_t branch_; }; @@ -14226,7 +14586,7 @@ namespace exprtk struct T0oT1oT2process { typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::bfunc_t bfunc_t; struct mode0 { @@ -14269,7 +14629,7 @@ namespace exprtk struct T0oT1oT20T3process { typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::bfunc_t bfunc_t; struct mode0 { @@ -14383,7 +14743,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,v_) \ + #define synthesis_node_type_define(T0_, T1_, v_) \ template \ struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; \ template \ @@ -14405,7 +14765,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, v_) \ template \ struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; \ template \ @@ -14427,7 +14787,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,T3_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, T3_, v_) \ template \ struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; \ template \ @@ -14452,33 +14812,33 @@ namespace exprtk #undef synthesis_node_type_define template - class T0oT1 : public expression_node + class T0oT1 exprtk_final : public expression_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::bfunc_t bfunc_t; typedef T value_type; typedef T0oT1 node_type; T0oT1(T0 p0, T1 p1, const bfunc_t p2) - : t0_(p0), - t1_(p1), - f_ (p2) + : t0_(p0) + , t1_(p1) + , f_ (p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_,t1_); } @@ -14510,8 +14870,8 @@ namespace exprtk private: - T0oT1(T0oT1&) {} - T0oT1& operator=(T0oT1&) { return (*this); } + T0oT1(const T0oT1&) exprtk_delete; + T0oT1& operator=(const T0oT1&) { return (*this); } T0 t0_; T1 t1_; @@ -14519,36 +14879,36 @@ namespace exprtk }; template - class T0oT1oT2 : public T0oT1oT2_base_node + class T0oT1oT2 exprtk_final : public T0oT1oT2_base_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::bfunc_t bfunc_t; typedef T value_type; typedef T0oT1oT2 node_type; typedef ProcessMode process_mode_t; T0oT1oT2(T0 p0, T1 p1, T2 p2, const bfunc_t p3, const bfunc_t p4) - : t0_(p0), - t1_(p1), - t2_(p2), - f0_(p3), - f1_(p4) + : t0_(p0) + , t1_(p1) + , t2_(p2) + , f0_(p3) + , f1_(p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, f0_, f1_); } @@ -14578,7 +14938,7 @@ namespace exprtk return f1_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -14598,8 +14958,8 @@ namespace exprtk private: - T0oT1oT2(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14609,12 +14969,12 @@ namespace exprtk }; template - class T0oT1oT2oT3 : public T0oT1oT2oT3_base_node + class T0oT1oT2oT3 exprtk_final : public T0oT1oT2oT3_base_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::bfunc_t bfunc_t; + typedef typename functor_t::bfunc_t bfunc_t; typedef T value_type; typedef T0_ T0; typedef T1_ T1; @@ -14624,16 +14984,16 @@ namespace exprtk typedef ProcessMode process_mode_t; T0oT1oT2oT3(T0 p0, T1 p1, T2 p2, T3 p3, bfunc_t p4, bfunc_t p5, bfunc_t p6) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3), - f0_(p4), - f1_(p5), - f2_(p6) + : t0_(p0) + , t1_(p1) + , t2_(p2) + , t3_(p3) + , f0_(p4) + , f1_(p5) + , f2_(p6) {} - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, t3_, f0_, f1_, f2_); } @@ -14673,7 +15033,7 @@ namespace exprtk return f2_; } - inline std::string type_id() const + inline std::string type_id() const exprtk_override { return id(); } @@ -14695,8 +15055,8 @@ namespace exprtk private: - T0oT1oT2oT3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14708,34 +15068,34 @@ namespace exprtk }; template - class T0oT1oT2_sf3 : public T0oT1oT2_base_node + class T0oT1oT2_sf3 exprtk_final : public T0oT1oT2_base_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; + typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; typedef T0oT1oT2_sf3 node_type; T0oT1oT2_sf3(T0 p0, T1 p1, T2 p2, const tfunc_t p3) - : t0_(p0), - t1_(p1), - t2_(p2), - f_ (p3) + : t0_(p0) + , t1_(p1) + , t2_(p2) + , f_ (p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_); } @@ -14780,8 +15140,8 @@ namespace exprtk private: - T0oT1oT2_sf3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14794,8 +15154,7 @@ namespace exprtk { public: - virtual ~sf3ext_type_node() - {} + virtual ~sf3ext_type_node() {} virtual T0 t0() const = 0; @@ -14805,53 +15164,53 @@ namespace exprtk }; template - class T0oT1oT2_sf3ext : public sf3ext_type_node + class T0oT1oT2_sf3ext exprtk_final : public sf3ext_type_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; + typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2_sf3ext node_type; + typedef T0oT1oT2_sf3ext node_type; T0oT1oT2_sf3ext(T0 p0, T1 p1, T2 p2) - : t0_(p0), - t1_(p1), - t2_(p2) + : t0_(p0) + , t1_(p1) + , t2_(p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return SF3Operation::process(t0_, t1_, t2_); } - T0 t0() const + T0 t0() const exprtk_override { return t0_; } - T1 t1() const + T1 t1() const exprtk_override { return t1_; } - T2 t2() const + T2 t2() const exprtk_override { return t2_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -14871,8 +15230,8 @@ namespace exprtk private: - T0oT1oT2_sf3ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14894,35 +15253,35 @@ namespace exprtk } template - class T0oT1oT2oT3_sf4 : public T0oT1oT2_base_node + class T0oT1oT2oT3_sf4 exprtk_final : public T0oT1oT2_base_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t qfunc_t; + typedef typename functor_t::qfunc_t qfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4 node_type; + typedef T0oT1oT2oT3_sf4 node_type; T0oT1oT2oT3_sf4(T0 p0, T1 p1, T2 p2, T3 p3, const qfunc_t p4) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3), - f_ (p4) + : t0_(p0) + , t1_(p1) + , t2_(p2) + , t3_(p3) + , f_ (p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_, t3_); } @@ -14972,8 +15331,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14983,34 +15342,29 @@ namespace exprtk }; template - class T0oT1oT2oT3_sf4ext : public T0oT1oT2oT3_base_node + class T0oT1oT2oT3_sf4ext exprtk_final : public T0oT1oT2oT3_base_node { public: typedef typename details::functor_t functor_t; - typedef typename functor_t::tfunc_t tfunc_t; + typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4ext node_type; + typedef T0oT1oT2oT3_sf4ext node_type; T0oT1oT2oT3_sf4ext(T0 p0, T1 p1, T2 p2, T3 p3) - : t0_(p0), - t1_(p1), - t2_(p2), - t3_(p3) + : t0_(p0) + , t1_(p1) + , t2_(p2) + , t3_(p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const - { - return e_default; - } - - inline T value() const + inline T value() const exprtk_override { return SF4Operation::process(t0_, t1_, t2_, t3_); } @@ -15035,7 +15389,7 @@ namespace exprtk return t3_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -15055,8 +15409,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15109,7 +15463,7 @@ namespace exprtk }; template - class vov_node : public vov_base_node + class vov_node exprtk_final : public vov_base_node { public: @@ -15118,31 +15472,31 @@ namespace exprtk // variable op variable node explicit vov_node(const T& var0, const T& var1) - : v0_(var0), - v1_(var1) + : v0_(var0) + , v1_(var1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v0_,v1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v0() const + inline const T& v0() const exprtk_override { return v0_; } - inline const T& v1() const + inline const T& v1() const exprtk_override { return v1_; } @@ -15154,12 +15508,12 @@ namespace exprtk private: - vov_node(vov_node&); - vov_node& operator=(vov_node&); + vov_node(const vov_node&) exprtk_delete; + vov_node& operator=(const vov_node&) exprtk_delete; }; template - class cov_node : public cov_base_node + class cov_node exprtk_final : public cov_base_node { public: @@ -15168,31 +15522,31 @@ namespace exprtk // constant op variable node explicit cov_node(const T& const_var, const T& var) - : c_(const_var), - v_(var) + : c_(const_var) + , v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(c_,v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15204,12 +15558,12 @@ namespace exprtk private: - cov_node(const cov_node&); - cov_node& operator=(const cov_node&); + cov_node(const cov_node&) exprtk_delete; + cov_node& operator=(const cov_node&) exprtk_delete; }; template - class voc_node : public voc_base_node + class voc_node exprtk_final : public voc_base_node { public: @@ -15218,26 +15572,26 @@ namespace exprtk // variable op constant node explicit voc_node(const T& var, const T& const_var) - : v_(var), - c_(const_var) + : v_(var) + , c_(const_var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_,c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15249,12 +15603,12 @@ namespace exprtk private: - voc_node(const voc_node&); - voc_node& operator=(const voc_node&); + voc_node(const voc_node&) exprtk_delete; + voc_node& operator=(const voc_node&) exprtk_delete; }; template - class vob_node : public vob_base_node + class vob_node exprtk_final : public vob_base_node { public: @@ -15269,48 +15623,43 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(v_,branch_.first->value()); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - vob_node(const vob_node&); - vob_node& operator=(const vob_node&); + vob_node(const vob_node&) exprtk_delete; + vob_node& operator=(const vob_node&) exprtk_delete; const T& v_; branch_t branch_; }; template - class bov_node : public bov_base_node + class bov_node exprtk_final : public bov_base_node { public: @@ -15325,48 +15674,43 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),v_); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bov_node(const bov_node&); - bov_node& operator=(const bov_node&); + bov_node(const bov_node&) exprtk_delete; + bov_node& operator=(const bov_node&) exprtk_delete; const T& v_; branch_t branch_; }; template - class cob_node : public cob_base_node + class cob_node exprtk_final : public cob_base_node { public: @@ -15381,59 +15725,59 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(c_,branch_.first->value()); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - cob_node(const cob_node&); - cob_node& operator=(const cob_node&); + cob_node(const cob_node&) exprtk_delete; + cob_node& operator=(const cob_node&) exprtk_delete; const T c_; branch_t branch_; }; template - class boc_node : public boc_base_node + class boc_node exprtk_final : public boc_base_node { public: @@ -15448,52 +15792,52 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - boc_node(const boc_node&); - boc_node& operator=(const boc_node&); + boc_node(const boc_node&) exprtk_delete; + boc_node& operator=(const boc_node&) exprtk_delete; const T c_; branch_t branch_; @@ -15501,7 +15845,7 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities template - class sos_node : public sos_base_node + class sos_node exprtk_final : public sos_base_node { public: @@ -15510,21 +15854,21 @@ namespace exprtk // string op string node explicit sos_node(SType0 p0, SType1 p1) - : s0_(p0), - s1_(p1) + : s0_(p0) + , s1_(p1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(s0_,s1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15546,23 +15890,24 @@ namespace exprtk private: - sos_node(sos_node&); - sos_node& operator=(sos_node&); + sos_node(const sos_node&) exprtk_delete; + sos_node& operator=(const sos_node&) exprtk_delete; }; template - class str_xrox_node : public sos_base_node + class str_xrox_node exprtk_final : public sos_base_node { public: typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xrox_node node_type; // string-range op string node explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) - : s0_ (p0 ), - s1_ (p1 ), - rp0_(rp0) + : s0_ (p0 ) + , s1_ (p1 ) + , rp0_(rp0) {} ~str_xrox_node() @@ -15570,7 +15915,7 @@ namespace exprtk rp0_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15581,12 +15926,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15609,23 +15954,24 @@ namespace exprtk private: - str_xrox_node(str_xrox_node&); - str_xrox_node& operator=(str_xrox_node&); + str_xrox_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template - class str_xoxr_node : public sos_base_node + class str_xoxr_node exprtk_final : public sos_base_node { public: typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xoxr_node node_type; // string op string range node explicit str_xoxr_node(SType0 p0, SType1 p1, RangePack rp1) - : s0_ (p0 ), - s1_ (p1 ), - rp1_(rp1) + : s0_ (p0 ) + , s1_ (p1 ) + , rp1_(rp1) {} ~str_xoxr_node() @@ -15633,7 +15979,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15644,12 +15990,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15672,24 +16018,25 @@ namespace exprtk private: - str_xoxr_node(str_xoxr_node&); - str_xoxr_node& operator=(str_xoxr_node&); + str_xoxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template - class str_xroxr_node : public sos_base_node + class str_xroxr_node exprtk_final : public sos_base_node { public: typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xroxr_node node_type; // string-range op string-range node explicit str_xroxr_node(SType0 p0, SType1 p1, RangePack rp0, RangePack rp1) - : s0_ (p0 ), - s1_ (p1 ), - rp0_(rp0), - rp1_(rp1) + : s0_ (p0 ) + , s1_ (p1 ) + , rp0_(rp0) + , rp1_(rp1) {} ~str_xroxr_node() @@ -15698,7 +16045,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0_0 = 0; std::size_t r0_1 = 0; @@ -15719,12 +16066,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15748,30 +16095,30 @@ namespace exprtk private: - str_xroxr_node(str_xroxr_node&); - str_xroxr_node& operator=(str_xroxr_node&); + str_xroxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template - class str_sogens_node : public binary_node + class str_sogens_node exprtk_final : public binary_node { public: typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; + typedef string_base_node* str_base_ptr; + typedef range_pack range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; str_sogens_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) - : binary_node(opr, branch0, branch1), - str0_base_ptr_ (0), - str1_base_ptr_ (0), - str0_range_ptr_(0), - str1_range_ptr_(0) + : binary_node(opr, branch0, branch1) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) { if (is_generally_string_node(binary_node::branch_[0].first)) { @@ -15804,7 +16151,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if ( str0_base_ptr_ && @@ -15840,20 +16187,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const - { - return Operation::operation(); - } - private: - str_sogens_node(str_sogens_node&); - str_sogens_node& operator=(str_sogens_node&); + str_sogens_node(const str_sogens_node&) exprtk_delete; + str_sogens_node& operator=(const str_sogens_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -15862,31 +16204,32 @@ namespace exprtk }; template - class sosos_node : public sosos_base_node + class sosos_node exprtk_final : public sosos_base_node { public: typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef sosos_node node_type; // variable op variable node explicit sosos_node(SType0 p0, SType1 p1, SType2 p2) - : s0_(p0), - s1_(p1), - s2_(p2) + : s0_(p0) + , s1_(p1) + , s2_(p2) {} - inline T value() const + inline T value() const exprtk_override { - return Operation::process(s0_,s1_,s2_); + return Operation::process(s0_, s1_, s2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15914,13 +16257,13 @@ namespace exprtk private: - sosos_node(sosos_node&); - sosos_node& operator=(sosos_node&); + sosos_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; #endif template - class ipow_node : public expression_node + class ipow_node exprtk_final: public expression_node { public: @@ -15931,26 +16274,26 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return PowOp::result(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } private: - ipow_node(const ipow_node&); - ipow_node& operator=(const ipow_node&); + ipow_node(const ipow_node&) exprtk_delete; + ipow_node& operator=(const ipow_node&) exprtk_delete; const T& v_; }; template - class bipow_node : public expression_node + class bipow_node exprtk_final : public expression_node { public: @@ -15963,37 +16306,37 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return PowOp::result(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipow_node(const bipow_node&); - bipow_node& operator=(const bipow_node&); + bipow_node(const bipow_node&) exprtk_delete; + bipow_node& operator=(const bipow_node&) exprtk_delete; branch_t branch_; }; template - class ipowinv_node : public expression_node + class ipowinv_node exprtk_final : public expression_node { public: @@ -16004,26 +16347,26 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return (T(1) / PowOp::result(v_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } private: - ipowinv_node(const ipowinv_node&); - ipowinv_node& operator=(const ipowinv_node&); + ipowinv_node(const ipowinv_node&) exprtk_delete; + ipowinv_node& operator=(const ipowinv_node&) exprtk_delete; const T& v_; }; template - class bipowninv_node : public expression_node + class bipowninv_node exprtk_final : public expression_node { public: @@ -16036,31 +16379,31 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return (T(1) / PowOp::result(branch_.first->value())); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipowninv_node(const bipowninv_node&); - bipowninv_node& operator=(const bipowninv_node&); + bipowninv_node(const bipowninv_node&) exprtk_delete; + bipowninv_node& operator=(const bipowninv_node&) exprtk_delete; branch_t branch_; }; @@ -16592,61 +16935,61 @@ namespace exprtk inline void load_operations_map(std::multimap& m) { - #define register_op(Symbol,Type,Args) \ + #define register_op(Symbol, Type, Args) \ m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ - register_op( "abs", e_abs , 1) - register_op( "acos", e_acos , 1) - register_op( "acosh", e_acosh , 1) - register_op( "asin", e_asin , 1) - register_op( "asinh", e_asinh , 1) - register_op( "atan", e_atan , 1) - register_op( "atanh", e_atanh , 1) - register_op( "ceil", e_ceil , 1) - register_op( "cos", e_cos , 1) - register_op( "cosh", e_cosh , 1) - register_op( "exp", e_exp , 1) - register_op( "expm1", e_expm1 , 1) - register_op( "floor", e_floor , 1) - register_op( "log", e_log , 1) - register_op( "log10", e_log10 , 1) - register_op( "log2", e_log2 , 1) - register_op( "log1p", e_log1p , 1) - register_op( "round", e_round , 1) - register_op( "sin", e_sin , 1) - register_op( "sinc", e_sinc , 1) - register_op( "sinh", e_sinh , 1) - register_op( "sec", e_sec , 1) - register_op( "csc", e_csc , 1) - register_op( "sqrt", e_sqrt , 1) - register_op( "tan", e_tan , 1) - register_op( "tanh", e_tanh , 1) - register_op( "cot", e_cot , 1) - register_op( "rad2deg", e_r2d , 1) - register_op( "deg2rad", e_d2r , 1) - register_op( "deg2grad", e_d2g , 1) - register_op( "grad2deg", e_g2d , 1) - register_op( "sgn", e_sgn , 1) - register_op( "not", e_notl , 1) - register_op( "erf", e_erf , 1) - register_op( "erfc", e_erfc , 1) - register_op( "ncdf", e_ncdf , 1) - register_op( "frac", e_frac , 1) - register_op( "trunc", e_trunc , 1) - register_op( "atan2", e_atan2 , 2) - register_op( "mod", e_mod , 2) - register_op( "logn", e_logn , 2) - register_op( "pow", e_pow , 2) - register_op( "root", e_root , 2) - register_op( "roundn", e_roundn , 2) - register_op( "equal", e_equal , 2) - register_op("not_equal", e_nequal , 2) - register_op( "hypot", e_hypot , 2) - register_op( "shr", e_shr , 2) - register_op( "shl", e_shl , 2) - register_op( "clamp", e_clamp , 3) - register_op( "iclamp", e_iclamp , 3) - register_op( "inrange", e_inrange , 3) + register_op("abs" , e_abs , 1) + register_op("acos" , e_acos , 1) + register_op("acosh" , e_acosh , 1) + register_op("asin" , e_asin , 1) + register_op("asinh" , e_asinh , 1) + register_op("atan" , e_atan , 1) + register_op("atanh" , e_atanh , 1) + register_op("ceil" , e_ceil , 1) + register_op("cos" , e_cos , 1) + register_op("cosh" , e_cosh , 1) + register_op("exp" , e_exp , 1) + register_op("expm1" , e_expm1 , 1) + register_op("floor" , e_floor , 1) + register_op("log" , e_log , 1) + register_op("log10" , e_log10 , 1) + register_op("log2" , e_log2 , 1) + register_op("log1p" , e_log1p , 1) + register_op("round" , e_round , 1) + register_op("sin" , e_sin , 1) + register_op("sinc" , e_sinc , 1) + register_op("sinh" , e_sinh , 1) + register_op("sec" , e_sec , 1) + register_op("csc" , e_csc , 1) + register_op("sqrt" , e_sqrt , 1) + register_op("tan" , e_tan , 1) + register_op("tanh" , e_tanh , 1) + register_op("cot" , e_cot , 1) + register_op("rad2deg" , e_r2d , 1) + register_op("deg2rad" , e_d2r , 1) + register_op("deg2grad" , e_d2g , 1) + register_op("grad2deg" , e_g2d , 1) + register_op("sgn" , e_sgn , 1) + register_op("not" , e_notl , 1) + register_op("erf" , e_erf , 1) + register_op("erfc" , e_erfc , 1) + register_op("ncdf" , e_ncdf , 1) + register_op("frac" , e_frac , 1) + register_op("trunc" , e_trunc , 1) + register_op("atan2" , e_atan2 , 2) + register_op("mod" , e_mod , 2) + register_op("logn" , e_logn , 2) + register_op("pow" , e_pow , 2) + register_op("root" , e_root , 2) + register_op("roundn" , e_roundn , 2) + register_op("equal" , e_equal , 2) + register_op("not_equal" , e_nequal , 2) + register_op("hypot" , e_hypot , 2) + register_op("shr" , e_shr , 2) + register_op("shl" , e_shl , 2) + register_op("clamp" , e_clamp , 3) + register_op("iclamp" , e_iclamp , 3) + register_op("inrange" , e_inrange , 3) #undef register_op } @@ -16657,10 +17000,10 @@ namespace exprtk public: function_traits() - : allow_zero_parameters_(false), - has_side_effects_(true), - min_num_args_(0), - max_num_args_(std::numeric_limits::max()) + : allow_zero_parameters_(false) + , has_side_effects_(true) + , min_num_args_(0) + , max_num_args_(std::numeric_limits::max()) {} inline bool& allow_zero_parameters() @@ -16744,8 +17087,7 @@ namespace exprtk : param_count(pc) {} - virtual ~ifunction() - {} + virtual ~ifunction() {} #define empty_method_body(N) \ { \ @@ -16836,8 +17178,7 @@ namespace exprtk { public: - virtual ~ivararg_function() - {} + virtual ~ivararg_function() {} inline virtual T operator() (const std::vector&) { @@ -16863,12 +17204,11 @@ namespace exprtk typedef typename generic_type::parameter_list parameter_list_t; igeneric_function(const std::string& param_seq = "", const return_type rtr_type = e_rtrn_scalar) - : parameter_sequence(param_seq), - rtrn_type(rtr_type) + : parameter_sequence(param_seq) + , rtrn_type(rtr_type) {} - virtual ~igeneric_function() - {} + virtual ~igeneric_function() {} #define igeneric_function_empty_body(N) \ { \ @@ -16896,6 +17236,43 @@ namespace exprtk return_type rtrn_type; }; + #ifndef exprtk_disable_string_capabilities + template + class stringvar_base + { + public: + + typedef typename details::stringvar_node stringvar_node_t; + + stringvar_base(const std::string& name, stringvar_node_t* svn) + : name_(name) + , string_varnode_(svn) + {} + + bool valid() const + { + return !name_.empty() && (0 != string_varnode_); + } + + std::string name() const + { + assert(string_varnode_); + return name_; + } + + void rebase(std::string& s) + { + assert(string_varnode_); + string_varnode_->rebase(s); + } + + private: + + std::string name_; + stringvar_node_t* string_varnode_; + }; + #endif + template class parser; template class expression_helper; @@ -17125,6 +17502,27 @@ namespace exprtk : size(0) {} + struct deleter + { + #define exprtk_define_process(Type) \ + static inline void process(std::pair& n) \ + { \ + delete n.second; \ + } \ + + exprtk_define_process(variable_node_t ) + exprtk_define_process(vector_t ) + #ifndef exprtk_disable_string_capabilities + exprtk_define_process(stringvar_node_t) + #endif + + #undef exprtk_define_process + + template + static inline void process(std::pair&) + {} + }; + inline bool symbol_exists(const std::string& symbol_name) const { if (symbol_name.empty()) @@ -17263,19 +17661,19 @@ namespace exprtk (symbol_name, v, is_const); } - inline bool add(const std::string& symbol_name, RawType& t, const bool is_const = false) + inline bool add(const std::string& symbol_name, RawType& t_, const bool is_const = false) { struct tie { - static inline std::pair make(T& t,const bool is_const = false) + static inline std::pair make(T& t, const bool is_constant = false) { - return std::make_pair(is_const, new variable_node_t(t)); + return std::make_pair(is_constant, new variable_node_t(t)); } #ifndef exprtk_disable_string_capabilities - static inline std::pair make(std::string& t,const bool is_const = false) + static inline std::pair make(std::string& t, const bool is_constant = false) { - return std::make_pair(is_const, new stringvar_node_t(t)); + return std::make_pair(is_constant, new stringvar_node_t(t)); } #endif @@ -17284,9 +17682,9 @@ namespace exprtk return std::make_pair(is_constant,&t); } - static inline std::pair make(vararg_function_t& t, const bool is_const = false) + static inline std::pair make(vararg_function_t& t, const bool is_constant = false) { - return std::make_pair(is_const,&t); + return std::make_pair(is_constant,&t); } static inline std::pair make(generic_function_t& t, const bool is_constant = false) @@ -17299,7 +17697,7 @@ namespace exprtk if (map.end() == itr) { - map[symbol_name] = tie::make(t,is_const); + map[symbol_name] = tie::make(t_,is_const); ++size; } @@ -17360,16 +17758,6 @@ namespace exprtk if (map.end() != itr) { - struct deleter - { - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair& n) { delete n.second; } - #ifndef exprtk_disable_string_capabilities - static inline void process(std::pair& n) { delete n.second; } - #endif - static inline void process(std::pair&) { } - }; - if (delete_node) { deleter::process((*itr).second); @@ -17406,16 +17794,6 @@ namespace exprtk inline void clear(const bool delete_node = true) { - struct deleter - { - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair& n) { delete n.second; } - static inline void process(std::pair&) { } - #ifndef exprtk_disable_string_capabilities - static inline void process(std::pair& n) { delete n.second; } - #endif - }; - if (!map.empty()) { if (delete_node) @@ -17481,20 +17859,20 @@ namespace exprtk } }; - typedef details::expression_node* expression_ptr; - typedef typename details::variable_node variable_t; - typedef typename details::vector_holder vector_holder_t; - typedef variable_t* variable_ptr; + typedef details::expression_node* expression_ptr; + typedef typename details::variable_node variable_t; + typedef typename details::vector_holder vector_holder_t; + typedef variable_t* variable_ptr; #ifndef exprtk_disable_string_capabilities typedef typename details::stringvar_node stringvar_t; - typedef stringvar_t* stringvar_ptr; + typedef stringvar_t* stringvar_ptr; #endif - typedef ifunction function_t; - typedef ivararg_function vararg_function_t; - typedef igeneric_function generic_function_t; - typedef function_t* function_ptr; - typedef vararg_function_t* vararg_function_ptr; - typedef generic_function_t* generic_function_ptr; + typedef ifunction function_t; + typedef ivararg_function vararg_function_t; + typedef igeneric_function generic_function_t; + typedef function_t* function_ptr; + typedef vararg_function_t* vararg_function_ptr; + typedef generic_function_t* generic_function_ptr; static const std::size_t lut_size = 256; @@ -17503,16 +17881,16 @@ namespace exprtk { struct st_data { - type_store,T> variable_store; + type_store variable_store; + type_store function_store; + type_store vararg_function_store; + type_store generic_function_store; + type_store string_function_store; + type_store overload_function_store; + type_store vector_store; #ifndef exprtk_disable_string_capabilities - type_store,std::string> stringvar_store; + type_store stringvar_store; #endif - type_store,ifunction > function_store; - type_store,ivararg_function > vararg_function_store; - type_store,igeneric_function > generic_function_store; - type_store,igeneric_function > string_function_store; - type_store,igeneric_function > overload_function_store; - type_store vector_store; st_data() { @@ -17558,13 +17936,13 @@ namespace exprtk }; control_block() - : ref_count(1), - data_(st_data::create()) + : ref_count(1) + , data_(st_data::create()) {} explicit control_block(st_data* data) - : ref_count(1), - data_(data) + : ref_count(1) + , data_(data) {} ~control_block() @@ -17741,6 +18119,24 @@ namespace exprtk else return local_data().stringvar_store.get(string_name); } + + inline stringvar_base get_stringvar_base(const std::string& string_name) const + { + static stringvar_base null_stringvar_base("",reinterpret_cast(0)); + if (!valid()) + return null_stringvar_base; + else if (!valid_symbol(string_name)) + return null_stringvar_base; + + stringvar_ptr stringvar = local_data().stringvar_store.get(string_name); + + if (0 == stringvar) + { + return null_stringvar_base; + } + + return stringvar_base(string_name,stringvar); + } #endif inline function_ptr get_function(const std::string& function_name) const @@ -17958,30 +18354,22 @@ namespace exprtk return false; else if (symbol_exists(function_name)) return false; - else if ( - ( - (generic_function_t::e_rtrn_scalar == function.rtrn_type) || - (generic_function_t::e_rtrn_string == function.rtrn_type) - ) && - std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|") - ) - return false; - else if ( - (generic_function_t::e_rtrn_overload == function.rtrn_type) && - std::string::npos != function.parameter_sequence.find_first_not_of("STVZ*?|:") - ) - return false; - - switch (function.rtrn_type) + else { - case generic_function_t::e_rtrn_scalar : - return local_data().generic_function_store.add(function_name,function); + switch (function.rtrn_type) + { + case generic_function_t::e_rtrn_scalar : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|")) ? + local_data().generic_function_store.add(function_name,function) : false; - case generic_function_t::e_rtrn_string : - return local_data().string_function_store.add(function_name,function); + case generic_function_t::e_rtrn_string : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|")) ? + local_data().string_function_store.add(function_name,function) : false; - case generic_function_t::e_rtrn_overload : - return local_data().overload_function_store.add(function_name,function); + case generic_function_t::e_rtrn_overload : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|:")) ? + local_data().overload_function_store.add(function_name,function) : false; + } } return false; @@ -18047,30 +18435,22 @@ namespace exprtk return false; else if (symbol_exists(function_name,false)) return false; - else if ( - ( - (generic_function_t::e_rtrn_scalar == function.rtrn_type) || - (generic_function_t::e_rtrn_string == function.rtrn_type) - ) && - std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|") - ) - return false; - else if ( - generic_function_t::e_rtrn_overload && - std::string::npos != function.parameter_sequence.find_first_not_of("STV*?|:") - ) - return false; - - switch (function.rtrn_type) + else { - case generic_function_t::e_rtrn_scalar : - return local_data().generic_function_store.add(function_name,function); + switch (function.rtrn_type) + { + case generic_function_t::e_rtrn_scalar : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|")) ? + local_data().generic_function_store.add(function_name,function) : false; - case generic_function_t::e_rtrn_string : - return local_data().string_function_store.add(function_name,function); + case generic_function_t::e_rtrn_string : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|")) ? + local_data().string_function_store.add(function_name,function) : false; - case generic_function_t::e_rtrn_overload : - return local_data().overload_function_store.add(function_name,function); + case generic_function_t::e_rtrn_overload : + return (std::string::npos == function.parameter_sequence.find_first_not_of("STVZ*?|:")) ? + local_data().overload_function_store.add(function_name,function) : false; + } } return false; @@ -18515,7 +18895,7 @@ namespace exprtk control_block* control_block_; friend class parser; - }; + }; // class symbol_table template class function_compositor; @@ -18526,8 +18906,8 @@ namespace exprtk private: typedef details::expression_node* expression_ptr; - typedef details::vector_holder* vector_holder_ptr; - typedef std::vector > symtab_list_t; + typedef details::vector_holder* vector_holder_ptr; + typedef std::vector > symtab_list_t; struct control_block { @@ -18544,15 +18924,15 @@ namespace exprtk struct data_pack { data_pack() - : pointer(0), - type(e_unknown), - size(0) + : pointer(0) + , type(e_unknown) + , size(0) {} data_pack(void* ptr, const data_type dt, const std::size_t sz = 0) - : pointer(ptr), - type(dt), - size(sz) + : pointer(ptr) + , type(dt) + , size(sz) {} void* pointer; @@ -18562,21 +18942,22 @@ namespace exprtk typedef std::vector local_data_list_t; typedef results_context results_context_t; + typedef control_block* cntrl_blck_ptr_t; control_block() - : ref_count(0), - expr (0), - results (0), - retinv_null(false), - return_invoked(&retinv_null) + : ref_count(0) + , expr (0) + , results (0) + , retinv_null(false) + , return_invoked(&retinv_null) {} explicit control_block(expression_ptr e) - : ref_count(1), - expr (e), - results (0), - retinv_null(false), - return_invoked(&retinv_null) + : ref_count(1) + , expr (e) + , results (0) + , retinv_null(false) + , return_invoked(&retinv_null) {} ~control_block() @@ -18598,13 +18979,13 @@ namespace exprtk case e_vecholder : delete reinterpret_cast(local_data_list[i].pointer); break; - case e_data : delete (T*)(local_data_list[i].pointer); + case e_data : delete reinterpret_cast(local_data_list[i].pointer); break; - case e_vecdata : delete [] (T*)(local_data_list[i].pointer); + case e_vecdata : delete [] reinterpret_cast(local_data_list[i].pointer); break; - case e_string : delete (std::string*)(local_data_list[i].pointer); + case e_string : delete reinterpret_cast(local_data_list[i].pointer); break; default : break; @@ -18618,12 +18999,12 @@ namespace exprtk } } - static inline control_block* create(expression_ptr e) + static inline cntrl_blck_ptr_t create(expression_ptr e) { return new control_block(e); } - static inline void destroy(control_block*& cntrl_blck) + static inline void destroy(cntrl_blck_ptr_t& cntrl_blck) { if (cntrl_blck) { @@ -18658,8 +19039,8 @@ namespace exprtk } expression(const expression& e) - : control_block_ (e.control_block_ ), - symbol_table_list_(e.symbol_table_list_) + : control_block_ (e.control_block_ ) + , symbol_table_list_(e.symbol_table_list_) { control_block_->ref_count++; } @@ -18888,7 +19269,7 @@ namespace exprtk friend class parser; friend class expression_helper; friend class function_compositor; - }; + }; // class expression template class expression_helper @@ -18949,9 +19330,9 @@ namespace exprtk struct type { type() - : mode(parser_error::e_unknown), - line_no (0), - column_no(0) + : mode(parser_error::e_unknown) + , line_no (0) + , column_no(0) {} lexer::token token; @@ -18982,9 +19363,9 @@ namespace exprtk const std::string& src_location = "") { type t; - t.mode = mode; - t.token = tk; - t.diagnostic = diagnostic; + t.mode = mode; + t.token = tk; + t.diagnostic = diagnostic; t.src_location = src_location; exprtk_debug(("%s\n",diagnostic .c_str())); return t; @@ -19073,92 +19454,87 @@ namespace exprtk enum precedence_level { - e_level00, - e_level01, - e_level02, - e_level03, - e_level04, - e_level05, - e_level06, - e_level07, - e_level08, - e_level09, - e_level10, - e_level11, - e_level12, - e_level13, - e_level14 + e_level00, e_level01, e_level02, e_level03, e_level04, + e_level05, e_level06, e_level07, e_level08, e_level09, + e_level10, e_level11, e_level12, e_level13, e_level14 }; - typedef const T& cref_t; - typedef const T const_t; - typedef ifunction F; - typedef ivararg_function VAF; - typedef igeneric_function GF; - typedef ifunction ifunction_t; - typedef ivararg_function ivararg_function_t; - typedef igeneric_function igeneric_function_t; - typedef details::expression_node expression_node_t; - typedef details::literal_node literal_node_t; - typedef details::unary_node unary_node_t; - typedef details::binary_node binary_node_t; - typedef details::trinary_node trinary_node_t; - typedef details::quaternary_node quaternary_node_t; - typedef details::conditional_node conditional_node_t; - typedef details::cons_conditional_node cons_conditional_node_t; - typedef details::while_loop_node while_loop_node_t; - typedef details::repeat_until_loop_node repeat_until_loop_node_t; - typedef details::for_loop_node for_loop_node_t; + typedef const T& cref_t; + typedef const T const_t; + typedef ifunction F; + typedef ivararg_function VAF; + typedef igeneric_function GF; + typedef ifunction ifunction_t; + typedef ivararg_function ivararg_function_t; + typedef igeneric_function igeneric_function_t; + typedef details::expression_node expression_node_t; + typedef details::literal_node literal_node_t; + typedef details::unary_node unary_node_t; + typedef details::binary_node binary_node_t; + typedef details::trinary_node trinary_node_t; + typedef details::quaternary_node quaternary_node_t; + typedef details::conditional_node conditional_node_t; + typedef details::cons_conditional_node cons_conditional_node_t; + typedef details::while_loop_node while_loop_node_t; + typedef details::repeat_until_loop_node repeat_until_loop_node_t; + typedef details::for_loop_node for_loop_node_t; + typedef details::while_loop_rtc_node while_loop_rtc_node_t; + typedef details::repeat_until_loop_rtc_node repeat_until_loop_rtc_node_t; + typedef details::for_loop_rtc_node for_loop_rtc_node_t; #ifndef exprtk_disable_break_continue - typedef details::while_loop_bc_node while_loop_bc_node_t; - typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; - typedef details::for_loop_bc_node for_loop_bc_node_t; + typedef details::while_loop_bc_node while_loop_bc_node_t; + typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; + typedef details::for_loop_bc_node for_loop_bc_node_t; + typedef details::while_loop_bc_rtc_node while_loop_bc_rtc_node_t; + typedef details::repeat_until_loop_bc_rtc_node repeat_until_loop_bc_rtc_node_t; + typedef details::for_loop_bc_rtc_node for_loop_bc_rtc_node_t; #endif - typedef details::switch_node switch_node_t; - typedef details::variable_node variable_node_t; - typedef details::vector_elem_node vector_elem_node_t; - typedef details::rebasevector_elem_node rebasevector_elem_node_t; - typedef details::rebasevector_celem_node rebasevector_celem_node_t; - typedef details::vector_node vector_node_t; - typedef details::range_pack range_t; + typedef details::switch_node switch_node_t; + typedef details::variable_node variable_node_t; + typedef details::vector_elem_node vector_elem_node_t; + typedef details::rebasevector_elem_node rebasevector_elem_node_t; + typedef details::rebasevector_celem_node rebasevector_celem_node_t; + typedef details::vector_node vector_node_t; + typedef details::range_pack range_t; #ifndef exprtk_disable_string_capabilities - typedef details::stringvar_node stringvar_node_t; - typedef details::string_literal_node string_literal_node_t; - typedef details::string_range_node string_range_node_t; - typedef details::const_string_range_node const_string_range_node_t; - typedef details::generic_string_range_node generic_string_range_node_t; - typedef details::string_concat_node string_concat_node_t; - typedef details::assignment_string_node assignment_string_node_t; - typedef details::assignment_string_range_node assignment_string_range_node_t; - typedef details::conditional_string_node conditional_string_node_t; - typedef details::cons_conditional_str_node cons_conditional_str_node_t; + typedef details::stringvar_node stringvar_node_t; + typedef details::string_literal_node string_literal_node_t; + typedef details::string_range_node string_range_node_t; + typedef details::const_string_range_node const_string_range_node_t; + typedef details::generic_string_range_node generic_string_range_node_t; + typedef details::string_concat_node string_concat_node_t; + typedef details::assignment_string_node assignment_string_node_t; + typedef details::assignment_string_range_node assignment_string_range_node_t; + typedef details::conditional_string_node conditional_string_node_t; + typedef details::cons_conditional_str_node cons_conditional_str_node_t; #endif typedef details::assignment_node assignment_node_t; - typedef details::assignment_vec_elem_node assignment_vec_elem_node_t; - typedef details::assignment_rebasevec_elem_node assignment_rebasevec_elem_node_t; + typedef details::assignment_vec_elem_node assignment_vec_elem_node_t; + typedef details::assignment_rebasevec_elem_node assignment_rebasevec_elem_node_t; typedef details::assignment_rebasevec_celem_node assignment_rebasevec_celem_node_t; - typedef details::assignment_vec_node assignment_vec_node_t; - typedef details::assignment_vecvec_node assignment_vecvec_node_t; - typedef details::scand_node scand_node_t; - typedef details::scor_node scor_node_t; - typedef lexer::token token_t; - typedef expression_node_t* expression_node_ptr; - typedef expression expression_t; - typedef symbol_table symbol_table_t; - typedef typename expression::symtab_list_t symbol_table_list_t; + typedef details::assignment_vec_node assignment_vec_node_t; + typedef details::assignment_vecvec_node assignment_vecvec_node_t; + typedef details::conditional_vector_node conditional_vector_node_t; + typedef details::scand_node scand_node_t; + typedef details::scor_node scor_node_t; + typedef lexer::token token_t; + typedef expression_node_t* expression_node_ptr; + typedef expression expression_t; + typedef symbol_table symbol_table_t; + typedef typename expression::symtab_list_t symbol_table_list_t; typedef details::vector_holder* vector_holder_ptr; - typedef typename details::functor_t functor_t; + typedef typename details::functor_t functor_t; typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; typedef details::operator_type operator_t; - typedef std::map unary_op_map_t; - typedef std::map binary_op_map_t; - typedef std::map trinary_op_map_t; + typedef std::map unary_op_map_t; + typedef std::map binary_op_map_t; + typedef std::map trinary_op_map_t; typedef std::map > sf3_map_t; typedef std::map > sf4_map_t; @@ -19167,28 +19543,28 @@ namespace exprtk typedef std::multimap base_ops_map_t; typedef std::set disabled_func_set_t; - typedef details::T0oT1_define vov_t; - typedef details::T0oT1_define cov_t; - typedef details::T0oT1_define voc_t; + typedef details::T0oT1_define vov_t; + typedef details::T0oT1_define cov_t; + typedef details::T0oT1_define voc_t; - typedef details::T0oT1oT2_define vovov_t; - typedef details::T0oT1oT2_define vovoc_t; - typedef details::T0oT1oT2_define vocov_t; - typedef details::T0oT1oT2_define covov_t; - typedef details::T0oT1oT2_define covoc_t; - typedef details::T0oT1oT2_define cocov_t; - typedef details::T0oT1oT2_define vococ_t; + typedef details::T0oT1oT2_define vovov_t; + typedef details::T0oT1oT2_define vovoc_t; + typedef details::T0oT1oT2_define vocov_t; + typedef details::T0oT1oT2_define covov_t; + typedef details::T0oT1oT2_define covoc_t; + typedef details::T0oT1oT2_define cocov_t; + typedef details::T0oT1oT2_define vococ_t; - typedef details::T0oT1oT2oT3_define vovovov_t; - typedef details::T0oT1oT2oT3_define vovovoc_t; - typedef details::T0oT1oT2oT3_define vovocov_t; - typedef details::T0oT1oT2oT3_define vocovov_t; - typedef details::T0oT1oT2oT3_define covovov_t; + typedef details::T0oT1oT2oT3_define vovovov_t; + typedef details::T0oT1oT2oT3_define vovovoc_t; + typedef details::T0oT1oT2oT3_define vovocov_t; + typedef details::T0oT1oT2oT3_define vocovov_t; + typedef details::T0oT1oT2oT3_define covovov_t; - typedef details::T0oT1oT2oT3_define covocov_t; - typedef details::T0oT1oT2oT3_define vocovoc_t; - typedef details::T0oT1oT2oT3_define covovoc_t; - typedef details::T0oT1oT2oT3_define vococov_t; + typedef details::T0oT1oT2oT3_define covocov_t; + typedef details::T0oT1oT2oT3_define vocovoc_t; + typedef details::T0oT1oT2oT3_define covovoc_t; + typedef details::T0oT1oT2oT3_define vococov_t; typedef results_context results_context_t; @@ -19206,28 +19582,28 @@ namespace exprtk }; typedef details::vector_holder vector_holder_t; - typedef variable_node_t* variable_node_ptr; - typedef vector_holder_t* vector_holder_ptr; - typedef expression_node_t* expression_node_ptr; + typedef variable_node_t* variable_node_ptr; + typedef vector_holder_t* vector_holder_ptr; + typedef expression_node_t* expression_node_ptr; #ifndef exprtk_disable_string_capabilities - typedef stringvar_node_t* stringvar_node_ptr; + typedef stringvar_node_t* stringvar_node_ptr; #endif scope_element() - : name("???"), - size (std::numeric_limits::max()), - index(std::numeric_limits::max()), - depth(std::numeric_limits::max()), - ref_count(0), - ip_index (0), - type (e_none), - active(false), - data (0), - var_node(0), - vec_node(0) - #ifndef exprtk_disable_string_capabilities - ,str_node(0) - #endif + : name("???") + , size (std::numeric_limits::max()) + , index(std::numeric_limits::max()) + , depth(std::numeric_limits::max()) + , ref_count(0) + , ip_index (0) + , type (e_none) + , active(false) + , data (0) + , var_node (0) + , vec_node (0) + #ifndef exprtk_disable_string_capabilities + , str_node(0) + #endif {} bool operator < (const scope_element& se) const @@ -19287,12 +19663,12 @@ namespace exprtk public: typedef expression_node_t* expression_node_ptr; - typedef variable_node_t* variable_node_ptr; - typedef parser parser_t; + typedef variable_node_t* variable_node_ptr; + typedef parser parser_t; explicit scope_element_manager(parser& p) - : parser_(p), - input_param_cnt_(0) + : parser_(p) + , input_param_cnt_(0) {} inline std::size_t size() const @@ -19401,26 +19777,24 @@ namespace exprtk inline void free_element(scope_element& se) { - #ifdef exprtk_enable_debugging exprtk_debug(("free_element() - se[%s]\n", se.name.c_str())); - #endif switch (se.type) { - case scope_element::e_variable : if (se.data ) delete (T*) se.data; - if (se.var_node) delete se.var_node; + case scope_element::e_variable : delete reinterpret_cast(se.data); + delete se.var_node; break; - case scope_element::e_vector : if (se.data ) delete[] (T*) se.data; - if (se.vec_node) delete se.vec_node; + case scope_element::e_vector : delete[] reinterpret_cast(se.data); + delete se.vec_node; break; - case scope_element::e_vecelem : if (se.var_node) delete se.var_node; + case scope_element::e_vecelem : delete se.var_node; break; #ifndef exprtk_disable_string_capabilities - case scope_element::e_string : if (se.data ) delete (std::string*) se.data; - if (se.str_node) delete se.str_node; + case scope_element::e_string : delete reinterpret_cast(se.data); + delete se.str_node; break; #endif @@ -19473,7 +19847,8 @@ namespace exprtk private: - scope_element_manager& operator=(const scope_element_manager&); + scope_element_manager(const scope_element_manager&) exprtk_delete; + scope_element_manager& operator=(const scope_element_manager&) exprtk_delete; parser_t& parser_; std::vector element_; @@ -19513,7 +19888,8 @@ namespace exprtk private: - scope_handler& operator=(const scope_handler&); + scope_handler(const scope_handler&) exprtk_delete; + scope_handler& operator=(const scope_handler&) exprtk_delete; parser_t& parser_; }; @@ -19525,8 +19901,8 @@ namespace exprtk typedef parser parser_t; explicit stack_limit_handler(parser& p) - : parser_(p), - limit_exceeded_(false) + : parser_(p) + , limit_exceeded_(false) { if (++parser_.state_.stack_depth > parser_.settings_.max_stack_depth_) { @@ -19551,7 +19927,8 @@ namespace exprtk private: - stack_limit_handler& operator=(const stack_limit_handler&); + stack_limit_handler(const stack_limit_handler&) exprtk_delete; + stack_limit_handler& operator=(const stack_limit_handler&) exprtk_delete; parser_t& parser_; bool limit_exceeded_; @@ -19561,14 +19938,14 @@ namespace exprtk { symbol_table_list_t symtab_list_; - typedef typename symbol_table_t::local_data_t local_data_t; - typedef typename symbol_table_t::variable_ptr variable_ptr; - typedef typename symbol_table_t::function_ptr function_ptr; + typedef typename symbol_table_t::local_data_t local_data_t; + typedef typename symbol_table_t::variable_ptr variable_ptr; + typedef typename symbol_table_t::function_ptr function_ptr; #ifndef exprtk_disable_string_capabilities typedef typename symbol_table_t::stringvar_ptr stringvar_ptr; #endif - typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; - typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; + typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; + typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; typedef typename symbol_table_t::generic_function_ptr generic_function_ptr; inline bool empty() const @@ -19827,7 +20204,7 @@ namespace exprtk continue; else if (!local_data(i).stringvar_store.symbol_exists(symbol_name)) continue; - else if ( local_data(i).stringvar_store.is_constant(symbol_name)) + else if (local_data(i).stringvar_store.is_constant(symbol_name)) return true; } @@ -20057,8 +20434,7 @@ namespace exprtk : mode(m) {} - virtual ~unknown_symbol_resolver() - {} + virtual ~unknown_symbol_resolver() {} virtual bool process(const std::string& /*unknown_symbol*/, usr_symbol_type& st, @@ -20112,12 +20488,12 @@ namespace exprtk typedef std::vector symbol_list_t; dependent_entity_collector(const std::size_t options = e_ct_none) - : options_(options), - collect_variables_ ((options_ & e_ct_variables ) == e_ct_variables ), - collect_functions_ ((options_ & e_ct_functions ) == e_ct_functions ), - collect_assignments_((options_ & e_ct_assignments) == e_ct_assignments), - return_present_ (false), - final_stmt_return_(false) + : options_(options) + , collect_variables_ ((options_ & e_ct_variables ) == e_ct_variables ) + , collect_functions_ ((options_ & e_ct_functions ) == e_ct_functions ) + , collect_assignments_((options_ & e_ct_assignments) == e_ct_assignments) + , return_present_ (false) + , final_stmt_return_(false) {} template "; case details::e_gte : return ">="; - case details::e_gt : return ">"; - default : return ""; + case details::e_gt : return ">" ; + default : return "" ; } } @@ -20893,21 +21270,21 @@ namespace exprtk typedef settings_store settings_t; parser(const settings_t& settings = settings_t()) - : settings_(settings), - resolve_unknown_symbol_(false), - results_context_(0), - unknown_symbol_resolver_(reinterpret_cast(0)), + : settings_(settings) + , resolve_unknown_symbol_(false) + , results_context_(0) + , unknown_symbol_resolver_(reinterpret_cast(0)) #ifdef _MSC_VER #pragma warning(push) #pragma warning (disable:4355) #endif - sem_(*this), + , sem_(*this) #ifdef _MSC_VER #pragma warning(pop) #endif - operator_joiner_2_(2), - operator_joiner_3_(3), - loop_runtime_check_(0) + , operator_joiner_2_(2) + , operator_joiner_3_(3) + , loop_runtime_check_(0) { init_precompilation(); @@ -20928,19 +21305,18 @@ namespace exprtk expression_generator_.set_strength_reduction_state(settings_.strength_reduction_enabled()); } - ~parser() - {} + ~parser() {} inline void init_precompilation() { - if (settings_.collect_variables_enabled()) - dec_.collect_variables() = true; + dec_.collect_variables() = + settings_.collect_variables_enabled(); - if (settings_.collect_functions_enabled()) - dec_.collect_functions() = true; + dec_.collect_functions() = + settings_.collect_functions_enabled(); - if (settings_.collect_assignments_enabled()) - dec_.collect_assignments() = true; + dec_.collect_assignments() = + settings_.collect_assignments_enabled(); if (settings_.replacer_enabled()) { @@ -21094,11 +21470,8 @@ namespace exprtk inline expression_t compile(const std::string& expression_string, symbol_table_t& symtab) { expression_t expression; - expression.register_symbol_table(symtab); - compile(expression_string,expression); - return expression; } @@ -21419,7 +21792,7 @@ namespace exprtk scoped_vec_delete sdd((*this),arg_list); lexer::token begin_token; - lexer::token end_token; + lexer::token end_token; for ( ; ; ) { @@ -21552,39 +21925,39 @@ namespace exprtk switch (current_token().type) { - case token_t::e_assign : current_state.set(e_level00,e_level00, details::e_assign); break; - case token_t::e_addass : current_state.set(e_level00,e_level00, details::e_addass); break; - case token_t::e_subass : current_state.set(e_level00,e_level00, details::e_subass); break; - case token_t::e_mulass : current_state.set(e_level00,e_level00, details::e_mulass); break; - case token_t::e_divass : current_state.set(e_level00,e_level00, details::e_divass); break; - case token_t::e_modass : current_state.set(e_level00,e_level00, details::e_modass); break; - case token_t::e_swap : current_state.set(e_level00,e_level00, details::e_swap ); break; - case token_t::e_lt : current_state.set(e_level05,e_level06, details:: e_lt); break; - case token_t::e_lte : current_state.set(e_level05,e_level06, details:: e_lte); break; - case token_t::e_eq : current_state.set(e_level05,e_level06, details:: e_eq); break; - case token_t::e_ne : current_state.set(e_level05,e_level06, details:: e_ne); break; - case token_t::e_gte : current_state.set(e_level05,e_level06, details:: e_gte); break; - case token_t::e_gt : current_state.set(e_level05,e_level06, details:: e_gt); break; - case token_t::e_add : current_state.set(e_level07,e_level08, details:: e_add); break; - case token_t::e_sub : current_state.set(e_level07,e_level08, details:: e_sub); break; - case token_t::e_div : current_state.set(e_level10,e_level11, details:: e_div); break; - case token_t::e_mul : current_state.set(e_level10,e_level11, details:: e_mul); break; - case token_t::e_mod : current_state.set(e_level10,e_level11, details:: e_mod); break; - case token_t::e_pow : current_state.set(e_level12,e_level12, details:: e_pow); break; + case token_t::e_assign : current_state.set(e_level00, e_level00, details::e_assign); break; + case token_t::e_addass : current_state.set(e_level00, e_level00, details::e_addass); break; + case token_t::e_subass : current_state.set(e_level00, e_level00, details::e_subass); break; + case token_t::e_mulass : current_state.set(e_level00, e_level00, details::e_mulass); break; + case token_t::e_divass : current_state.set(e_level00, e_level00, details::e_divass); break; + case token_t::e_modass : current_state.set(e_level00, e_level00, details::e_modass); break; + case token_t::e_swap : current_state.set(e_level00, e_level00, details::e_swap ); break; + case token_t::e_lt : current_state.set(e_level05, e_level06, details::e_lt ); break; + case token_t::e_lte : current_state.set(e_level05, e_level06, details::e_lte ); break; + case token_t::e_eq : current_state.set(e_level05, e_level06, details::e_eq ); break; + case token_t::e_ne : current_state.set(e_level05, e_level06, details::e_ne ); break; + case token_t::e_gte : current_state.set(e_level05, e_level06, details::e_gte ); break; + case token_t::e_gt : current_state.set(e_level05, e_level06, details::e_gt ); break; + case token_t::e_add : current_state.set(e_level07, e_level08, details::e_add ); break; + case token_t::e_sub : current_state.set(e_level07, e_level08, details::e_sub ); break; + case token_t::e_div : current_state.set(e_level10, e_level11, details::e_div ); break; + case token_t::e_mul : current_state.set(e_level10, e_level11, details::e_mul ); break; + case token_t::e_mod : current_state.set(e_level10, e_level11, details::e_mod ); break; + case token_t::e_pow : current_state.set(e_level12, e_level12, details::e_pow ); break; default : if (token_t::e_symbol == current_token().type) { - static const std::string s_and = "and"; - static const std::string s_nand = "nand"; - static const std::string s_or = "or"; - static const std::string s_nor = "nor"; - static const std::string s_xor = "xor"; - static const std::string s_xnor = "xnor"; - static const std::string s_in = "in"; - static const std::string s_like = "like"; + static const std::string s_and = "and" ; + static const std::string s_nand = "nand" ; + static const std::string s_or = "or" ; + static const std::string s_nor = "nor" ; + static const std::string s_xor = "xor" ; + static const std::string s_xnor = "xnor" ; + static const std::string s_in = "in" ; + static const std::string s_like = "like" ; static const std::string s_ilike = "ilike"; - static const std::string s_and1 = "&"; - static const std::string s_or1 = "|"; - static const std::string s_not = "not"; + static const std::string s_and1 = "&" ; + static const std::string s_or1 = "|" ; + static const std::string s_not = "not" ; if (details::imatch(current_token().value,s_and)) { @@ -21725,11 +22098,11 @@ namespace exprtk if (0 != (right_branch = parse_expression(current_state.right))) { if ( - details::is_return_node( expression) || + details::is_return_node(expression ) || details::is_return_node(right_branch) ) { - free_node(node_allocator_, expression); + free_node(node_allocator_, expression ); free_node(node_allocator_, right_branch); set_error( @@ -21762,7 +22135,7 @@ namespace exprtk exprtk_error_location)); } - free_node(node_allocator_, expression); + free_node(node_allocator_, expression ); free_node(node_allocator_, right_branch); return error_node(); @@ -21771,7 +22144,7 @@ namespace exprtk { if ( token_is(token_t::e_ternary,prsrhlpr_t::e_hold) && - (precedence == e_level00) + (e_level00 == precedence) ) { expression = parse_ternary_conditional_statement(new_expression); @@ -21863,9 +22236,9 @@ namespace exprtk struct scoped_expression_delete { scoped_expression_delete(parser& pr, expression_node_ptr& expression) - : delete_ptr(true), - parser_(pr), - expression_(expression) + : delete_ptr(true) + , parser_(pr) + , expression_(expression) {} ~scoped_expression_delete() @@ -21882,7 +22255,8 @@ namespace exprtk private: - scoped_expression_delete& operator=(const scoped_expression_delete&); + scoped_expression_delete(const scoped_expression_delete&) exprtk_delete; + scoped_expression_delete& operator=(const scoped_expression_delete&) exprtk_delete; }; template @@ -21891,15 +22265,15 @@ namespace exprtk typedef Type* ptr_t; scoped_delete(parser& pr, ptr_t& p) - : delete_ptr(true), - parser_(pr), - p_(&p) + : delete_ptr(true) + , parser_(pr) + , p_(&p) {} scoped_delete(parser& pr, ptr_t (&p)[N]) - : delete_ptr(true), - parser_(pr), - p_(&p[0]) + : delete_ptr(true) + , parser_(pr) + , p_(&p[0]) {} ~scoped_delete() @@ -21919,7 +22293,8 @@ namespace exprtk private: - scoped_delete& operator=(const scoped_delete&); + scoped_delete(const scoped_delete&) exprtk_delete; + scoped_delete& operator=(const scoped_delete&) exprtk_delete; }; template @@ -21928,9 +22303,9 @@ namespace exprtk typedef Type* ptr_t; scoped_deq_delete(parser& pr, std::deque& deq) - : delete_ptr(true), - parser_(pr), - deq_(deq) + : delete_ptr(true) + , parser_(pr) + , deq_(deq) {} ~scoped_deq_delete() @@ -21952,7 +22327,8 @@ namespace exprtk private: - scoped_deq_delete& operator=(const scoped_deq_delete&); + scoped_deq_delete(const scoped_deq_delete&) exprtk_delete; + scoped_deq_delete& operator=(const scoped_deq_delete&) exprtk_delete; }; template @@ -21961,9 +22337,9 @@ namespace exprtk typedef Type* ptr_t; scoped_vec_delete(parser& pr, std::vector& vec) - : delete_ptr(true), - parser_(pr), - vec_(vec) + : delete_ptr(true) + , parser_(pr) + , vec_(vec) {} ~scoped_vec_delete() @@ -21985,7 +22361,8 @@ namespace exprtk private: - scoped_vec_delete& operator=(const scoped_vec_delete&); + scoped_vec_delete(const scoped_vec_delete&) exprtk_delete; + scoped_vec_delete& operator=(const scoped_vec_delete&) exprtk_delete; }; struct scoped_bool_negator @@ -22003,8 +22380,8 @@ namespace exprtk struct scoped_bool_or_restorer { explicit scoped_bool_or_restorer(bool& bb) - : b(bb), - original_value_(bb) + : b(bb) + , original_value_(bb) {} ~scoped_bool_or_restorer() @@ -22166,7 +22543,7 @@ namespace exprtk else result = expression_generator_.function(function,branch); - sd.delete_ptr = false; + sd.delete_ptr = (0 == result); return result; } @@ -22396,7 +22773,7 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities if (result) { - const bool consq_is_str = is_generally_string_node( consequent); + const bool consq_is_str = is_generally_string_node(consequent ); const bool alter_is_str = is_generally_string_node(alternative); if (consq_is_str || alter_is_str) @@ -22410,7 +22787,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR037 - Return types of ternary if-statement differ", + "ERR037 - Return types of if-statement differ: string/non-string", exprtk_error_location)); result = false; @@ -22418,6 +22795,29 @@ namespace exprtk } #endif + if (result) + { + const bool consq_is_vec = is_ivector_node(consequent ); + const bool alter_is_vec = is_ivector_node(alternative); + + if (consq_is_vec || alter_is_vec) + { + if (consq_is_vec && alter_is_vec) + { + return expression_generator_ + .conditional_vector(condition, consequent, alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR038 - Return types of if-statement differ: vector/non-vector", + exprtk_error_location)); + + result = false; + } + } + if (!result) { free_node(node_allocator_, condition ); @@ -22445,7 +22845,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR038 - Failed to parse body of consequent for if-statement", + "ERR039 - Failed to parse body of consequent for if-statement", exprtk_error_location)); result = false; @@ -22468,7 +22868,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR039 - Expected ';' at the end of the consequent for if-statement", + "ERR040 - Expected ';' at the end of the consequent for if-statement", exprtk_error_location)); result = false; @@ -22479,7 +22879,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR040 - Failed to parse body of consequent for if-statement", + "ERR041 - Failed to parse body of consequent for if-statement", exprtk_error_location)); result = false; @@ -22499,7 +22899,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR041 - Failed to parse body of the 'else' for if-statement", + "ERR042 - Failed to parse body of the 'else' for if-statement", exprtk_error_location)); result = false; @@ -22512,7 +22912,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR042 - Failed to parse body of if-else statement", + "ERR043 - Failed to parse body of if-else statement", exprtk_error_location)); result = false; @@ -22525,7 +22925,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR043 - Expected ';' at the end of the 'else-if' for the if-statement", + "ERR044 - Expected ';' at the end of the 'else-if' for the if-statement", exprtk_error_location)); result = false; @@ -22536,7 +22936,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR044 - Failed to parse body of the 'else' for if-statement", + "ERR045 - Failed to parse body of the 'else' for if-statement", exprtk_error_location)); result = false; @@ -22547,7 +22947,7 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities if (result) { - const bool consq_is_str = is_generally_string_node( consequent); + const bool consq_is_str = is_generally_string_node(consequent ); const bool alter_is_str = is_generally_string_node(alternative); if (consq_is_str || alter_is_str) @@ -22561,7 +22961,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR045 - Return types of ternary if-statement differ", + "ERR046 - Return types of if-statement differ: string/non-string", exprtk_error_location)); result = false; @@ -22569,10 +22969,33 @@ namespace exprtk } #endif + if (result) + { + const bool consq_is_vec = is_ivector_node(consequent ); + const bool alter_is_vec = is_ivector_node(alternative); + + if (consq_is_vec || alter_is_vec) + { + if (consq_is_vec && alter_is_vec) + { + return expression_generator_ + .conditional_vector(condition, consequent, alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR047 - Return types of if-statement differ: vector/non-vector", + exprtk_error_location)); + + result = false; + } + } + if (!result) { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); + free_node(node_allocator_, condition ); + free_node(node_allocator_, consequent ); free_node(node_allocator_, alternative); return error_node(); @@ -22593,7 +23016,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR046 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'", + "ERR048 - Expected '(' at start of if-statement, instead got: '" + current_token().value + "'", exprtk_error_location)); return error_node(); @@ -22603,7 +23026,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR047 - Failed to parse condition for if-statement", + "ERR049 - Failed to parse condition for if-statement", exprtk_error_location)); return error_node(); @@ -22615,27 +23038,29 @@ namespace exprtk } else if (token_is(token_t::e_rbracket)) { - // 00. if (x) y; - // 01. if (x) y; else z; - // 02. if (x) y; else {z0; ... zn;} - // 03. if (x) y; else if (z) w; - // 04. if (x) y; else if (z) w; else u; - // 05. if (x) y; else if (z) w; else {u0; ... un;} - // 06. if (x) y; else if (z) {w0; ... wn;} - // 07. if (x) {y0; ... yn;} - // 08. if (x) {y0; ... yn;} else z; - // 09. if (x) {y0; ... yn;} else {z0; ... zn;}; - // 10. if (x) {y0; ... yn;} else if (z) w; - // 11. if (x) {y0; ... yn;} else if (z) w; else u; - // 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} - // 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + /* + 00. if (x) y; + 01. if (x) y; else z; + 02. if (x) y; else {z0; ... zn;} + 03. if (x) y; else if (z) w; + 04. if (x) y; else if (z) w; else u; + 05. if (x) y; else if (z) w; else {u0; ... un;} + 06. if (x) y; else if (z) {w0; ... wn;} + 07. if (x) {y0; ... yn;} + 08. if (x) {y0; ... yn;} else z; + 09. if (x) {y0; ... yn;} else {z0; ... zn;}; + 10. if (x) {y0; ... yn;} else if (z) w; + 11. if (x) {y0; ... yn;} else if (z) w; else u; + 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} + 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + */ return parse_conditional_statement_02(condition); } set_error( make_error(parser_error::e_syntax, current_token(), - "ERR048 - Invalid if-statement", + "ERR050 - Invalid if-statement", exprtk_error_location)); free_node(node_allocator_,condition); @@ -22656,7 +23081,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR049 - Encountered invalid condition branch for ternary if-statement", + "ERR051 - Encountered invalid condition branch for ternary if-statement", exprtk_error_location)); return error_node(); @@ -22666,7 +23091,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR050 - Expected '?' after condition of ternary if-statement", + "ERR052 - Expected '?' after condition of ternary if-statement", exprtk_error_location)); result = false; @@ -22676,7 +23101,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR051 - Failed to parse consequent for ternary if-statement", + "ERR053 - Failed to parse consequent for ternary if-statement", exprtk_error_location)); result = false; @@ -22686,7 +23111,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR052 - Expected ':' between ternary if-statement consequent and alternative", + "ERR054 - Expected ':' between ternary if-statement consequent and alternative", exprtk_error_location)); result = false; @@ -22696,7 +23121,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR053 - Failed to parse alternative for ternary if-statement", + "ERR055 - Failed to parse alternative for ternary if-statement", exprtk_error_location)); result = false; @@ -22705,7 +23130,7 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities if (result) { - const bool consq_is_str = is_generally_string_node( consequent); + const bool consq_is_str = is_generally_string_node(consequent ); const bool alter_is_str = is_generally_string_node(alternative); if (consq_is_str || alter_is_str) @@ -22719,7 +23144,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR054 - Return types of ternary if-statement differ", + "ERR056 - Return types of ternary differ: string/non-string", exprtk_error_location)); result = false; @@ -22727,10 +23152,33 @@ namespace exprtk } #endif + if (result) + { + const bool consq_is_vec = is_ivector_node(consequent ); + const bool alter_is_vec = is_ivector_node(alternative); + + if (consq_is_vec || alter_is_vec) + { + if (consq_is_vec && alter_is_vec) + { + return expression_generator_ + .conditional_vector(condition, consequent, alternative); + } + + set_error( + make_error(parser_error::e_syntax, + current_token(), + "ERR057 - Return types of ternary differ: vector/non-vector", + exprtk_error_location)); + + result = false; + } + } + if (!result) { - free_node(node_allocator_, condition); - free_node(node_allocator_, consequent); + free_node(node_allocator_, condition ); + free_node(node_allocator_, consequent ); free_node(node_allocator_, alternative); return error_node(); @@ -22747,7 +23195,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR055 - Invalid or disabled logic operation 'not'", + "ERR058 - Invalid or disabled logic operation 'not'", exprtk_error_location)); return error_node(); @@ -22772,7 +23220,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR056 - Expected '(' at start of while-loop condition statement", + "ERR059 - Expected '(' at start of while-loop condition statement", exprtk_error_location)); return error_node(); @@ -22782,7 +23230,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR057 - Failed to parse condition for while-loop", + "ERR060 - Failed to parse condition for while-loop", exprtk_error_location)); return error_node(); @@ -22792,7 +23240,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR058 - Expected ')' at end of while-loop condition statement", + "ERR061 - Expected ')' at end of while-loop condition statement", exprtk_error_location)); result = false; @@ -22809,7 +23257,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR059 - Failed to parse body of while-loop")); + "ERR062 - Failed to parse body of while-loop")); result = false; } else if (0 == (result_node = expression_generator_.while_loop(condition, @@ -22819,7 +23267,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR060 - Failed to synthesize while-loop", + "ERR063 - Failed to synthesize while-loop", exprtk_error_location)); result = false; @@ -22828,8 +23276,8 @@ namespace exprtk if (!result) { - free_node(node_allocator_, branch); - free_node(node_allocator_, condition); + free_node(node_allocator_, branch ); + free_node(node_allocator_, condition ); free_node(node_allocator_, result_node); brkcnt_list_.pop_front(); @@ -22897,7 +23345,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR061 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop", + "ERR064 - Expected '" + token_t::to_str(seperator) + "' in body of repeat until loop", exprtk_error_location)); return error_node(); @@ -22921,7 +23369,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR062 - Failed to parse body of repeat until loop", + "ERR065 - Failed to parse body of repeat until loop", exprtk_error_location)); return error_node(); @@ -22935,7 +23383,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR063 - Expected '(' before condition statement of repeat until loop", + "ERR066 - Expected '(' before condition statement of repeat until loop", exprtk_error_location)); free_node(node_allocator_,branch); @@ -22949,7 +23397,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR064 - Failed to parse condition for repeat until loop", + "ERR067 - Failed to parse condition for repeat until loop", exprtk_error_location)); free_node(node_allocator_,branch); @@ -22961,10 +23409,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR065 - Expected ')' after condition of repeat until loop", + "ERR068 - Expected ')' after condition of repeat until loop", exprtk_error_location)); - free_node(node_allocator_, branch); + free_node(node_allocator_, branch ); free_node(node_allocator_, condition); brkcnt_list_.pop_front(); @@ -22982,7 +23430,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR066 - Failed to synthesize repeat until loop", + "ERR069 - Failed to synthesize repeat until loop", exprtk_error_location)); free_node(node_allocator_,condition); @@ -23017,7 +23465,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR067 - Expected '(' at start of for-loop", + "ERR070 - Expected '(' at start of for-loop", exprtk_error_location)); return error_node(); @@ -23037,7 +23485,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR068 - Expected a variable at the start of initialiser section of for-loop", + "ERR071 - Expected a variable at the start of initialiser section of for-loop", exprtk_error_location)); return error_node(); @@ -23047,7 +23495,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR069 - Expected variable assignment of initialiser section of for-loop", + "ERR072 - Expected variable assignment of initialiser section of for-loop", exprtk_error_location)); return error_node(); @@ -23062,7 +23510,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR070 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration", + "ERR073 - For-loop variable '" + loop_counter_symbol+ "' is being shadowed by a previous declaration", exprtk_error_location)); return error_node(); @@ -23072,7 +23520,7 @@ namespace exprtk if ( !se->active && (se->name == loop_counter_symbol) && - (se->type == scope_element::e_variable) + (se->type == scope_element::e_variable) ) { se->active = true; @@ -23087,14 +23535,14 @@ namespace exprtk nse.type = scope_element::e_variable; nse.depth = state_.scope_depth; nse.data = new T(T(0)); - nse.var_node = node_allocator_.allocate(*(T*)(nse.data)); + nse.var_node = node_allocator_.allocate(*reinterpret_cast(nse.data)); if (!sem_.add_element(nse)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR071 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM", + "ERR074 - Failed to add new local variable '" + loop_counter_symbol + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -23116,7 +23564,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR072 - Failed to parse initialiser of for-loop", + "ERR075 - Failed to parse initialiser of for-loop", exprtk_error_location)); result = false; @@ -23126,7 +23574,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR073 - Expected ';' after initialiser of for-loop", + "ERR076 - Expected ';' after initialiser of for-loop", exprtk_error_location)); result = false; @@ -23140,7 +23588,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR074 - Failed to parse condition of for-loop", + "ERR077 - Failed to parse condition of for-loop", exprtk_error_location)); result = false; @@ -23150,7 +23598,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR075 - Expected ';' after condition section of for-loop", + "ERR078 - Expected ';' after condition section of for-loop", exprtk_error_location)); result = false; @@ -23164,7 +23612,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR076 - Failed to parse incrementor of for-loop", + "ERR079 - Failed to parse incrementor of for-loop", exprtk_error_location)); result = false; @@ -23174,7 +23622,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR077 - Expected ')' after incrementor section of for-loop", + "ERR080 - Expected ')' after incrementor section of for-loop", exprtk_error_location)); result = false; @@ -23192,7 +23640,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR078 - Failed to parse body of for-loop", + "ERR081 - Failed to parse body of for-loop", exprtk_error_location)); result = false; @@ -23207,9 +23655,9 @@ namespace exprtk } free_node(node_allocator_, initialiser); - free_node(node_allocator_, condition); + free_node(node_allocator_, condition ); free_node(node_allocator_, incrementor); - free_node(node_allocator_, loop_body); + free_node(node_allocator_, loop_body ); if (!brkcnt_list_.empty()) { @@ -23242,7 +23690,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR079 - Expected keyword 'switch'", + "ERR082 - Expected keyword 'switch'", exprtk_error_location)); return error_node(); @@ -23257,7 +23705,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR080 - Expected '{' for call to switch statement", + "ERR083 - Expected '{' for call to switch statement", exprtk_error_location)); return error_node(); @@ -23282,7 +23730,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR081 - Expected ':' for case of switch statement", + "ERR084 - Expected ':' for case of switch statement", exprtk_error_location)); free_node(node_allocator_, condition); @@ -23303,10 +23751,10 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR082 - Expected ';' at end of case for switch statement", + "ERR085 - Expected ';' at end of case for switch statement", exprtk_error_location)); - free_node(node_allocator_, condition); + free_node(node_allocator_, condition ); free_node(node_allocator_, consequent); return error_node(); @@ -23315,12 +23763,12 @@ namespace exprtk // Can we optimise away the case statement? if (is_constant_node(condition) && is_false(condition)) { - free_node(node_allocator_, condition); + free_node(node_allocator_, condition ); free_node(node_allocator_, consequent); } else { - arg_list.push_back( condition); + arg_list.push_back(condition ); arg_list.push_back(consequent); } @@ -23332,7 +23780,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR083 - Multiple default cases for switch statement", + "ERR086 - Multiple default cases for switch statement", exprtk_error_location)); return error_node(); @@ -23345,7 +23793,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR084 - Expected ':' for default of switch statement", + "ERR087 - Expected ':' for default of switch statement", exprtk_error_location)); return error_node(); @@ -23363,7 +23811,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR085 - Expected ';' at end of default for switch statement", + "ERR088 - Expected ';' at end of default for switch statement", exprtk_error_location)); return error_node(); @@ -23376,7 +23824,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR086 - Expected '}' at end of switch statement", + "ERR089 - Expected '}' at end of switch statement", exprtk_error_location)); return error_node(); @@ -23407,7 +23855,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR087 - Expected token '[*]'", + "ERR090 - Expected token '[*]'", exprtk_error_location)); return error_node(); @@ -23422,7 +23870,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR088 - Expected '{' for call to [*] statement", + "ERR091 - Expected '{' for call to [*] statement", exprtk_error_location)); return error_node(); @@ -23435,7 +23883,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR089 - Expected a 'case' statement for multi-switch", + "ERR092 - Expected a 'case' statement for multi-switch", exprtk_error_location)); return error_node(); @@ -23453,7 +23901,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR090 - Expected ':' for case of [*] statement", + "ERR093 - Expected ':' for case of [*] statement", exprtk_error_location)); return error_node(); @@ -23469,7 +23917,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR091 - Expected ';' at end of case for [*] statement", + "ERR094 - Expected ';' at end of case for [*] statement", exprtk_error_location)); return error_node(); @@ -23478,12 +23926,12 @@ namespace exprtk // Can we optimise away the case statement? if (is_constant_node(condition) && is_false(condition)) { - free_node(node_allocator_, condition); + free_node(node_allocator_, condition ); free_node(node_allocator_, consequent); } else { - arg_list.push_back( condition); + arg_list.push_back(condition ); arg_list.push_back(consequent); } @@ -23498,7 +23946,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR092 - Expected '}' at end of [*] statement", + "ERR095 - Expected '}' at end of [*] statement", exprtk_error_location)); return error_node(); @@ -23539,7 +23987,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR093 - Unsupported vararg function: " + symbol, + "ERR096 - Unsupported vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -23556,7 +24004,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR094 - Expected '(' for call to vararg function: " + symbol, + "ERR097 - Expected '(' for call to vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -23578,7 +24026,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR095 - Expected ',' for call to vararg function: " + symbol, + "ERR098 - Expected ',' for call to vararg function: " + symbol, exprtk_error_location)); return error_node(); @@ -23599,7 +24047,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR096 - Expected '[' as start of string range definition", + "ERR099 - Expected '[' as start of string range definition", exprtk_error_location)); free_node(node_allocator_,expression); @@ -23627,10 +24075,11 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR097 - Failed to generate string range node", + "ERR100 - Failed to generate string range node", exprtk_error_location)); free_node(node_allocator_,expression); + rp.free(); } rp.clear(); @@ -23732,8 +24181,8 @@ namespace exprtk } if ( - return_node_present || - side_effect_list.back() || + return_node_present || + side_effect_list.back() || (expression_list.size() > 1) ) state_.activate_side_effect("simplify()"); @@ -23763,7 +24212,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR098 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + + "ERR101 - Expected '" + token_t::to_str(close_bracket) + "' for call to multi-sequence" + ((!source.empty()) ? std::string(" section of " + source): ""), exprtk_error_location)); @@ -23810,7 +24259,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR099 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source, + "ERR102 - Expected '" + details::to_str(seperator) + "' for call to multi-sequence section of " + source, exprtk_error_location)); return error_node(); @@ -23844,7 +24293,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR100 - Expected '[' for start of range", + "ERR103 - Expected '[' for start of range", exprtk_error_location)); return false; @@ -23865,7 +24314,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR101 - Failed parse begin section of range", + "ERR104 - Failed parse begin section of range", exprtk_error_location)); return false; @@ -23888,7 +24337,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR102 - Range lower bound less than zero! Constraint: r0 >= 0", + "ERR105 - Range lower bound less than zero! Constraint: r0 >= 0", exprtk_error_location)); return false; @@ -23905,7 +24354,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR103 - Expected ':' for break in range", + "ERR106 - Expected ':' for break in range", exprtk_error_location)); rp.free(); @@ -23928,7 +24377,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR104 - Failed parse end section of range", + "ERR107 - Failed parse end section of range", exprtk_error_location)); rp.free(); @@ -23953,9 +24402,11 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR105 - Range upper bound less than zero! Constraint: r1 >= 0", + "ERR108 - Range upper bound less than zero! Constraint: r1 >= 0", exprtk_error_location)); + rp.free(); + return false; } } @@ -23970,7 +24421,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR106 - Expected ']' for start of range", + "ERR109 - Expected ']' for start of range", exprtk_error_location)); rp.free(); @@ -23998,7 +24449,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR107 - Invalid range, Constraint: r0 <= r1", + "ERR110 - Invalid range, Constraint: r0 <= r1", exprtk_error_location)); return false; @@ -24039,7 +24490,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR108 - Unknown string symbol", + "ERR111 - Unknown string symbol", exprtk_error_location)); return error_node(); @@ -24154,7 +24605,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR109 - Overflow in range for string: '" + const_str + "'[" + + "ERR112 - Overflow in range for string: '" + const_str + "'[" + (rp.n0_c.first ? details::to_str(static_cast(rp.n0_c.second)) : "?") + ":" + (rp.n1_c.first ? details::to_str(static_cast(rp.n1_c.second)) : "?") + "]", exprtk_error_location)); @@ -24200,7 +24651,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR110 - Symbol '" + symbol+ " not a vector", + "ERR113 - Symbol '" + symbol+ " not a vector", exprtk_error_location)); return error_node(); @@ -24226,7 +24677,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR111 - Failed to parse index for vector: '" + symbol + "'", + "ERR114 - Failed to parse index for vector: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -24236,7 +24687,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR112 - Expected ']' for index of vector: '" + symbol + "'", + "ERR115 - Expected ']' for index of vector: '" + symbol + "'", exprtk_error_location)); free_node(node_allocator_,index_expr); @@ -24255,7 +24706,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR113 - Index of " + details::to_str(index) + " out of range for " + "ERR116 - Index of " + details::to_str(index) + " out of range for " "vector '" + symbol + "' of size " + details::to_str(vec_size), exprtk_error_location)); @@ -24287,7 +24738,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR114 - Zero parameter call to vararg function: " + "ERR117 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed", exprtk_error_location)); @@ -24312,7 +24763,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR115 - Expected ',' for call to vararg function: " + "ERR118 - Expected ',' for call to vararg function: " + vararg_function_name, exprtk_error_location)); @@ -24326,7 +24777,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR116 - Zero parameter call to vararg function: " + "ERR119 - Zero parameter call to vararg function: " + vararg_function_name + " not allowed", exprtk_error_location)); @@ -24338,7 +24789,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR117 - Invalid number of parameters to call to vararg function: " + "ERR120 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require at least " + details::to_str(static_cast(vararg_function->min_num_args())) + " parameters", exprtk_error_location)); @@ -24350,7 +24801,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR118 - Invalid number of parameters to call to vararg function: " + "ERR121 - Invalid number of parameters to call to vararg function: " + vararg_function_name + ", require no more than " + details::to_str(static_cast(vararg_function->max_num_args())) + " parameters", exprtk_error_location)); @@ -24389,19 +24840,14 @@ namespace exprtk const std::string& func_name, const std::string& func_prototypes, const return_type_t default_return_type) - : invalid_state_(true), - parser_(p), - function_name_(func_name), - default_return_type_(default_return_type) + : invalid_state_(true) + , parser_(p) + , function_name_(func_name) + , default_return_type_(default_return_type) { parse_function_prototypes(func_prototypes); } - void set_default_return_type(const std::string& return_type) - { - default_return_type_ = return_type; - } - bool verify(const std::string& param_seq, std::size_t& pseq_index) { if (function_definition_list_.empty()) @@ -24433,9 +24879,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR119 - Failed parameter type check for function '" + function_name_ + "', " + "ERR122 - Failed parameter type check for function '" + function_name_ + "', " "Expected '" + function_definition_list_[0].param_seq + - "' call set: '" + param_seq + "'", + "' call set: '" + param_seq + "'", exprtk_error_location)); } else @@ -24455,9 +24901,9 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR120 - Failed parameter type check for function '" + function_name_ + "', " + "ERR123 - Failed parameter type check for function '" + function_name_ + "', " "Best match: '" + function_definition_list_[max_diff_index].param_seq + - "' call set: '" + param_seq + "'", + "' call set: '" + param_seq + "'", exprtk_error_location)); } @@ -24597,7 +25043,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR121 - Invalid parameter sequence of '" + param_seq_list[i] + + "ERR124 - Invalid parameter sequence of '" + param_seq_list[i] + "' for function: " + function_name_, exprtk_error_location)); return; @@ -24613,7 +25059,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, parser_.current_token(), - "ERR122 - Function '" + function_name_ + "' has a parameter sequence conflict between " + + "ERR125 - Function '" + function_name_ + "' has a parameter sequence conflict between " + "pseq_idx[" + details::to_str(seq_itr->second) + "] and" + "pseq_idx[" + details::to_str(i) + "] " + "param seq: " + param_seq_list[i], @@ -24625,8 +25071,8 @@ namespace exprtk } } - type_checker(const type_checker&); - type_checker& operator=(const type_checker&); + type_checker(const type_checker&) exprtk_delete; + type_checker& operator=(const type_checker&) exprtk_delete; bool invalid_state_; parser_t& parser_; @@ -24652,7 +25098,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR123 - Type checker instantiation failure for generic function: " + function_name, + "ERR126 - Type checker instantiation failure for generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -24670,7 +25116,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR124 - Zero parameter call to generic function: " + "ERR127 - Zero parameter call to generic function: " + function_name + " not allowed", exprtk_error_location)); @@ -24702,7 +25148,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR125 - Expected ',' for call to generic function: " + function_name, + "ERR128 - Expected ',' for call to generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -24719,7 +25165,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR126 - Zero parameter call to generic function: " + "ERR129 - Zero parameter call to generic function: " + function_name + " not allowed", exprtk_error_location)); @@ -24736,7 +25182,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR127 - Invalid input parameter sequence for call to generic function: " + function_name, + "ERR130 - Invalid input parameter sequence for call to generic function: " + function_name, exprtk_error_location)); return error_node(); @@ -24774,7 +25220,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR128 - Zero parameter call to generic function: " + "ERR131 - Zero parameter call to generic function: " + function_name + " not allowed", exprtk_error_location)); @@ -24806,7 +25252,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR129 - Expected ',' for call to string function: " + function_name, + "ERR132 - Expected ',' for call to string function: " + function_name, exprtk_error_location)); return false; @@ -24853,7 +25299,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR130 - Invalid input parameter sequence for call to string function: " + function_name, + "ERR133 - Invalid input parameter sequence for call to string function: " + function_name, exprtk_error_location)); return error_node(); @@ -24905,7 +25351,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR131 - Invalid input parameter sequence for call to overloaded function: " + function_name, + "ERR134 - Invalid input parameter sequence for call to overloaded function: " + function_name, exprtk_error_location)); return error_node(); @@ -24936,7 +25382,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR132 - Invalid return type for call to overloaded function: " + function_name, + "ERR135 - Invalid return type for call to overloaded function: " + function_name, exprtk_error_location)); } @@ -24964,7 +25410,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR133 - Expected '(' for special function '" + sf_name + "'", + "ERR136 - Expected '(' for special function '" + sf_name + "'", exprtk_error_location)); return error_node(); @@ -24985,7 +25431,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR134 - Expected ',' before next parameter of special function '" + sf_name + "'", + "ERR137 - Expected ',' before next parameter of special function '" + sf_name + "'", exprtk_error_location)); return p.error_node(); @@ -24998,7 +25444,7 @@ namespace exprtk p.set_error( make_error(parser_error::e_syntax, p.current_token(), - "ERR135 - Invalid number of parameters for special function '" + sf_name + "'", + "ERR138 - Invalid number of parameters for special function '" + sf_name + "'", exprtk_error_location)); return p.error_node(); @@ -25025,7 +25471,7 @@ namespace exprtk set_error( make_error(parser_error::e_token, current_token(), - "ERR136 - Invalid special function[1]: " + sf_name, + "ERR139 - Invalid special function[1]: " + sf_name, exprtk_error_location)); return error_node(); @@ -25039,7 +25485,7 @@ namespace exprtk set_error( make_error(parser_error::e_token, current_token(), - "ERR137 - Invalid special function[2]: " + sf_name, + "ERR140 - Invalid special function[2]: " + sf_name, exprtk_error_location)); return error_node(); @@ -25071,7 +25517,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR138 - Invoking 'break' within a break call is not allowed", + "ERR141 - Invoking 'break' within a break call is not allowed", exprtk_error_location)); return error_node(); @@ -25081,7 +25527,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR139 - Invalid use of 'break', allowed only in the scope of a loop", + "ERR142 - Invalid use of 'break', allowed only in the scope of a loop", exprtk_error_location)); return error_node(); @@ -25104,7 +25550,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR140 - Failed to parse return expression for 'break' statement", + "ERR143 - Failed to parse return expression for 'break' statement", exprtk_error_location)); return error_node(); @@ -25114,7 +25560,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR141 - Expected ']' at the completion of break's return expression", + "ERR144 - Expected ']' at the completion of break's return expression", exprtk_error_location)); free_node(node_allocator_,return_expr); @@ -25132,7 +25578,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR142 - Invalid use of 'break', allowed only in the scope of a loop", + "ERR145 - Invalid use of 'break', allowed only in the scope of a loop", exprtk_error_location)); } @@ -25146,7 +25592,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR143 - Invalid use of 'continue', allowed only in the scope of a loop", + "ERR146 - Invalid use of 'continue', allowed only in the scope of a loop", exprtk_error_location)); return error_node(); @@ -25172,7 +25618,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR144 - Expected '[' as part of vector size definition", + "ERR147 - Expected '[' as part of vector size definition", exprtk_error_location)); return error_node(); @@ -25182,7 +25628,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR145 - Failed to determine size of vector '" + vec_name + "'", + "ERR148 - Failed to determine size of vector '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -25194,7 +25640,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR146 - Expected a literal number as size of vector '" + vec_name + "'", + "ERR149 - Expected a literal number as size of vector '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -25216,7 +25662,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR147 - Invalid vector size. Must be an integer in the range [0,2e9], size: " + + "ERR150 - Invalid vector size. Must be an integer in the range [0,2e9], size: " + details::to_str(details::numeric::to_int32(vector_size)), exprtk_error_location)); @@ -25236,7 +25682,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR148 - Expected ']' as part of vector size definition", + "ERR151 - Expected ']' as part of vector size definition", exprtk_error_location)); return error_node(); @@ -25248,7 +25694,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR149 - Expected ':=' as part of vector definition", + "ERR152 - Expected ':=' as part of vector definition", exprtk_error_location)); return error_node(); @@ -25262,7 +25708,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR150 - Failed to parse single vector initialiser", + "ERR153 - Failed to parse single vector initialiser", exprtk_error_location)); return error_node(); @@ -25275,7 +25721,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR151 - Expected ']' to close single value vector initialiser", + "ERR154 - Expected ']' to close single value vector initialiser", exprtk_error_location)); return error_node(); @@ -25322,7 +25768,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR152 - Expected '{' as part of vector initialiser list", + "ERR155 - Expected '{' as part of vector initialiser list", exprtk_error_location)); return error_node(); @@ -25342,7 +25788,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR153 - Expected '{' as part of vector initialiser list", + "ERR156 - Expected '{' as part of vector initialiser list", exprtk_error_location)); return error_node(); @@ -25360,7 +25806,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR154 - Expected ',' between vector initialisers", + "ERR157 - Expected ',' between vector initialisers", exprtk_error_location)); return error_node(); @@ -25382,7 +25828,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR155 - Expected ';' at end of vector definition", + "ERR158 - Expected ';' at end of vector definition", exprtk_error_location)); return error_node(); @@ -25394,7 +25840,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR156 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'", + "ERR159 - Initialiser list larger than the number of elements in the vector: '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -25414,7 +25860,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR157 - Illegal redefinition of local vector: '" + vec_name + "'", + "ERR160 - Illegal redefinition of local vector: '" + vec_name + "'", exprtk_error_location)); return error_node(); @@ -25441,14 +25887,14 @@ namespace exprtk nse.depth = state_.scope_depth; nse.size = vec_size; nse.data = new T[vec_size]; - nse.vec_node = new typename scope_element::vector_holder_t((T*)(nse.data),nse.size); + nse.vec_node = new typename scope_element::vector_holder_t(reinterpret_cast(nse.data),nse.size); if (!sem_.add_element(nse)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR158 - Failed to add new local vector '" + vec_name + "' to SEM", + "ERR161 - Failed to add new local vector '" + vec_name + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -25507,7 +25953,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR159 - Illegal redefinition of local variable: '" + str_name + "'", + "ERR162 - Illegal redefinition of local variable: '" + str_name + "'", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -25532,14 +25978,14 @@ namespace exprtk nse.type = scope_element::e_string; nse.depth = state_.scope_depth; nse.data = new std::string; - nse.str_node = new stringvar_node_t(*(std::string*)(nse.data)); + nse.str_node = new stringvar_node_t(*reinterpret_cast(nse.data)); if (!sem_.add_element(nse)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR160 - Failed to add new local string variable '" + str_name + "' to SEM", + "ERR163 - Failed to add new local string variable '" + str_name + "' to SEM", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -25585,7 +26031,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR161 - Illegal variable definition", + "ERR164 - Illegal variable definition", exprtk_error_location)); return error_node(); @@ -25606,7 +26052,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR162 - Expected a symbol for variable definition", + "ERR165 - Expected a symbol for variable definition", exprtk_error_location)); return error_node(); @@ -25616,7 +26062,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR163 - Illegal redefinition of reserved keyword: '" + var_name + "'", + "ERR166 - Illegal redefinition of reserved keyword: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -25626,7 +26072,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR164 - Illegal redefinition of variable '" + var_name + "'", + "ERR167 - Illegal redefinition of variable '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -25636,7 +26082,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR165 - Illegal redefinition of local variable: '" + var_name + "'", + "ERR168 - Illegal redefinition of local variable: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -25656,7 +26102,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR166 - Failed to parse initialisation expression", + "ERR169 - Failed to parse initialisation expression", exprtk_error_location)); return error_node(); @@ -25674,7 +26120,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR167 - Expected ';' after variable definition", + "ERR170 - Expected ';' after variable definition", exprtk_error_location)); free_node(node_allocator_,initialisation_expression); @@ -25702,7 +26148,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR168 - Illegal redefinition of local variable: '" + var_name + "'", + "ERR171 - Illegal redefinition of local variable: '" + var_name + "'", exprtk_error_location)); free_node(node_allocator_, initialisation_expression); @@ -25727,14 +26173,14 @@ namespace exprtk nse.type = scope_element::e_variable; nse.depth = state_.scope_depth; nse.data = new T(T(0)); - nse.var_node = node_allocator_.allocate(*(T*)(nse.data)); + nse.var_node = node_allocator_.allocate(*reinterpret_cast(nse.data)); if (!sem_.add_element(nse)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR169 - Failed to add new local variable '" + var_name + "' to SEM", + "ERR172 - Failed to add new local variable '" + var_name + "' to SEM", exprtk_error_location)); free_node(node_allocator_, initialisation_expression); @@ -25771,7 +26217,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR170 - Expected a '{}' for uninitialised var definition", + "ERR173 - Expected a '{}' for uninitialised var definition", exprtk_error_location)); return error_node(); @@ -25781,7 +26227,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR171 - Expected ';' after uninitialised variable definition", + "ERR174 - Expected ';' after uninitialised variable definition", exprtk_error_location)); return error_node(); @@ -25798,7 +26244,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR172 - Illegal redefinition of local variable: '" + var_name + "'", + "ERR175 - Illegal redefinition of local variable: '" + var_name + "'", exprtk_error_location)); return error_node(); @@ -25821,14 +26267,14 @@ namespace exprtk nse.depth = state_.scope_depth; nse.ip_index = sem_.next_ip_index(); nse.data = new T(T(0)); - nse.var_node = node_allocator_.allocate(*(T*)(nse.data)); + nse.var_node = node_allocator_.allocate(*reinterpret_cast(nse.data)); if (!sem_.add_element(nse)) { set_error( make_error(parser_error::e_syntax, current_token(), - "ERR173 - Failed to add new local variable '" + var_name + "' to SEM", + "ERR176 - Failed to add new local variable '" + var_name + "' to SEM", exprtk_error_location)); sem_.free_element(nse); @@ -25861,7 +26307,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR174 - Expected '(' at start of swap statement", + "ERR177 - Expected '(' at start of swap statement", exprtk_error_location)); return error_node(); @@ -25880,7 +26326,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR175 - Expected a symbol for variable or vector element definition", + "ERR178 - Expected a symbol for variable or vector element definition", exprtk_error_location)); return error_node(); @@ -25892,7 +26338,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR176 - First parameter to swap is an invalid vector element: '" + var0_name + "'", + "ERR179 - First parameter to swap is an invalid vector element: '" + var0_name + "'", exprtk_error_location)); return error_node(); @@ -25925,7 +26371,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR177 - First parameter to swap is an invalid variable: '" + var0_name + "'", + "ERR180 - First parameter to swap is an invalid variable: '" + var0_name + "'", exprtk_error_location)); return error_node(); @@ -25939,7 +26385,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR178 - Expected ',' between parameters to swap", + "ERR181 - Expected ',' between parameters to swap", exprtk_error_location)); if (variable0_generated) @@ -25957,7 +26403,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR179 - Expected a symbol for variable or vector element definition", + "ERR182 - Expected a symbol for variable or vector element definition", exprtk_error_location)); if (variable0_generated) @@ -25974,7 +26420,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR180 - Second parameter to swap is an invalid vector element: '" + var1_name + "'", + "ERR183 - Second parameter to swap is an invalid vector element: '" + var1_name + "'", exprtk_error_location)); if (variable0_generated) @@ -26012,7 +26458,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR181 - Second parameter to swap is an invalid variable: '" + var1_name + "'", + "ERR184 - Second parameter to swap is an invalid variable: '" + var1_name + "'", exprtk_error_location)); if (variable0_generated) @@ -26031,7 +26477,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR182 - Expected ')' at end of swap statement", + "ERR185 - Expected ')' at end of swap statement", exprtk_error_location)); if (variable0_generated) @@ -26088,7 +26534,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR183 - Return call within a return call is not allowed", + "ERR186 - Return call within a return call is not allowed", exprtk_error_location)); return error_node(); @@ -26112,7 +26558,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR184 - Expected '[' at start of return statement", + "ERR187 - Expected '[' at start of return statement", exprtk_error_location)); return error_node(); @@ -26135,7 +26581,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR185 - Expected ',' between values during call to return", + "ERR188 - Expected ',' between values during call to return", exprtk_error_location)); return error_node(); @@ -26147,7 +26593,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR186 - Zero parameter return statement not allowed", + "ERR189 - Zero parameter return statement not allowed", exprtk_error_location)); return error_node(); @@ -26162,7 +26608,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, prev_token, - "ERR187 - Invalid ']' found during return call", + "ERR190 - Invalid ']' found during return call", exprtk_error_location)); return error_node(); @@ -26215,7 +26661,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR188 - Invalid sequence of variable '"+ symbol + "' and bracket", + "ERR191 - Invalid sequence of variable '"+ symbol + "' and bracket", exprtk_error_location)); return false; @@ -26231,7 +26677,7 @@ namespace exprtk { bool implied_mul = false; - if (is_generally_string_node(branch)) + if (details::is_generally_string_node(branch)) return true; const lexer::parser_helper::token_advance_mode hold = prsrhlpr_t::e_hold; @@ -26263,7 +26709,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR189 - Invalid sequence of brackets", + "ERR192 - Invalid sequence of brackets", exprtk_error_location)); return false; @@ -26360,7 +26806,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR190 - Failed to generate node for function: '" + symbol + "'", + "ERR193 - Failed to generate node for function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26386,7 +26832,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR191 - Failed to generate node for vararg function: '" + symbol + "'", + "ERR194 - Failed to generate node for vararg function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26412,7 +26858,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR192 - Failed to generate node for generic function: '" + symbol + "'", + "ERR195 - Failed to generate node for generic function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26439,7 +26885,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR193 - Failed to generate node for string function: '" + symbol + "'", + "ERR196 - Failed to generate node for string function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26465,7 +26911,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR194 - Failed to generate node for overload function: '" + symbol + "'", + "ERR197 - Failed to generate node for overload function: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26491,7 +26937,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR195 - Invalid use of reserved symbol '" + symbol + "'", + "ERR198 - Invalid use of reserved symbol '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26554,7 +27000,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR196 - Failed to create variable: '" + symbol + "'" + + "ERR199 - Failed to create variable: '" + symbol + "'" + (error_message.empty() ? "" : " - " + error_message), exprtk_error_location)); @@ -26574,7 +27020,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR197 - Failed to resolve symbol: '" + symbol + "'" + + "ERR200 - Failed to resolve symbol: '" + symbol + "'" + (error_message.empty() ? "" : " - " + error_message), exprtk_error_location)); } @@ -26586,7 +27032,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR198 - Undefined symbol: '" + symbol + "'", + "ERR201 - Undefined symbol: '" + symbol + "'", exprtk_error_location)); return error_node(); @@ -26607,83 +27053,85 @@ namespace exprtk static const std::string symbol_return = "return" ; static const std::string symbol_not = "not" ; - if (valid_vararg_operation(current_token().value)) + const std::string symbol = current_token().value; + + if (valid_vararg_operation(symbol)) { return parse_vararg_function(); } - else if (details::imatch(current_token().value, symbol_not)) + else if (details::imatch(symbol, symbol_not)) { return parse_not_statement(); } - else if (valid_base_operation(current_token().value)) + else if (valid_base_operation(symbol)) { return parse_base_operation(); } else if ( - details::imatch(current_token().value, symbol_if) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_if) && + settings_.control_struct_enabled(symbol) ) { return parse_conditional_statement(); } else if ( - details::imatch(current_token().value, symbol_while) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_while) && + settings_.control_struct_enabled(symbol) ) { return parse_while_loop(); } else if ( - details::imatch(current_token().value, symbol_repeat) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_repeat) && + settings_.control_struct_enabled(symbol) ) { return parse_repeat_until_loop(); } else if ( - details::imatch(current_token().value, symbol_for) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_for) && + settings_.control_struct_enabled(symbol) ) { return parse_for_loop(); } else if ( - details::imatch(current_token().value, symbol_switch) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_switch) && + settings_.control_struct_enabled(symbol) ) { return parse_switch_statement(); } - else if (details::is_valid_sf_symbol(current_token().value)) + else if (details::is_valid_sf_symbol(symbol)) { return parse_special_function(); } - else if (details::imatch(current_token().value, symbol_null)) + else if (details::imatch(symbol, symbol_null)) { return parse_null_statement(); } #ifndef exprtk_disable_break_continue - else if (details::imatch(current_token().value, symbol_break)) + else if (details::imatch(symbol, symbol_break)) { return parse_break_statement(); } - else if (details::imatch(current_token().value, symbol_continue)) + else if (details::imatch(symbol, symbol_continue)) { return parse_continue_statement(); } #endif - else if (details::imatch(current_token().value, symbol_var)) + else if (details::imatch(symbol, symbol_var)) { return parse_define_var_statement(); } - else if (details::imatch(current_token().value, symbol_swap)) + else if (details::imatch(symbol, symbol_swap)) { return parse_swap_statement(); } #ifndef exprtk_disable_return_statement else if ( - details::imatch(current_token().value, symbol_return) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_return) && + settings_.control_struct_enabled(symbol) ) { return parse_return_statement(); @@ -26698,7 +27146,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR199 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, + "ERR202 - Variable or function detected, yet symbol-table is invalid, Symbol: " + symbol, exprtk_error_location)); return error_node(); @@ -26729,7 +27177,7 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR200 - Failed generate node for scalar: '" + current_token().value + "'", + "ERR203 - Failed generate node for scalar: '" + current_token().value + "'", exprtk_error_location)); return error_node(); @@ -26743,7 +27191,7 @@ namespace exprtk set_error( make_error(parser_error::e_numeric, current_token(), - "ERR201 - Failed to convert '" + current_token().value + "' to a number", + "ERR204 - Failed to convert '" + current_token().value + "' to a number", exprtk_error_location)); return error_node(); @@ -26770,16 +27218,16 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR202 - Expected ')' instead of: '" + current_token().value + "'", + "ERR205 - Expected ')' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -26795,16 +27243,16 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR203 - Expected ']' instead of: '" + current_token().value + "'", + "ERR206 - Expected ']' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lsqrbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -26820,16 +27268,16 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR204 - Expected '}' instead of: '" + current_token().value + "'", + "ERR207 - Expected '}' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lcrlbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -26851,7 +27299,7 @@ namespace exprtk if (0 == result) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -26869,7 +27317,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR205 - Premature end of expression[1]", + "ERR208 - Premature end of expression[1]", exprtk_error_location)); return error_node(); @@ -26879,7 +27327,7 @@ namespace exprtk set_error( make_error(parser_error::e_syntax, current_token(), - "ERR206 - Premature end of expression[2]", + "ERR209 - Premature end of expression[2]", exprtk_error_location)); return error_node(); @@ -27581,9 +28029,9 @@ namespace exprtk (details::e_equal == operation) || (details::e_and == operation) || (details::e_nand == operation) || - (details:: e_or == operation) || - (details:: e_nor == operation) || - (details:: e_xor == operation) || + (details::e_or == operation) || + (details::e_nor == operation) || + (details::e_xor == operation) || (details::e_xnor == operation) ); } @@ -27782,9 +28230,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, consequent); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -27794,16 +28242,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -27828,9 +28276,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, consequent); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -27840,16 +28288,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -27873,6 +28321,51 @@ namespace exprtk } #endif + inline expression_node_ptr conditional_vector(expression_node_ptr condition, + expression_node_ptr consequent, + expression_node_ptr alternative) const + { + if ((0 == condition) || (0 == consequent)) + { + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); + + return error_node(); + } + // Can the condition be immediately evaluated? if so optimise. + else if (details::is_constant_node(condition)) + { + // True branch + if (details::is_true(condition)) + { + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); + + return consequent; + } + // False branch + else + { + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); + + if (alternative) + return alternative; + else + return node_allocator_->allocate >(); + + } + } + else if ((0 != consequent) && (0 != alternative)) + { + return node_allocator_-> + allocate(condition, consequent, alternative); + } + else + return error_node(); + } + inline loop_runtime_check_ptr get_loop_runtime_check(const loop_runtime_check::loop_types loop_type) const { if ( @@ -27888,9 +28381,9 @@ namespace exprtk inline expression_node_ptr while_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); if (details::is_true(condition)) @@ -27899,32 +28392,39 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return result; } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_while_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -27932,9 +28432,9 @@ namespace exprtk inline expression_node_ptr repeat_until_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { if ( details::is_true(condition) && @@ -27946,32 +28446,39 @@ namespace exprtk return branch; } - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return error_node(); } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -27981,9 +28488,9 @@ namespace exprtk expression_node_ptr& condition, expression_node_ptr& incrementor, expression_node_ptr& loop_body, - bool brkcont = false) const + bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); @@ -27993,43 +28500,67 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition); - free_node(*node_allocator_, incrementor); - free_node(*node_allocator_, loop_body); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, loop_body ); return result; } else if (details::is_null_node(condition) || (0 == condition)) { - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition); - free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); return loop_body; } - else if (!brkcont) - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_for_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #else - return error_node(); + return error_node(); #endif } @@ -28098,7 +28629,7 @@ namespace exprtk if (current_expr && (current_expr != result)) { - free_node(*node_allocator_,current_expr); + details::free_node(*node_allocator_,current_expr); } } @@ -28112,49 +28643,57 @@ namespace exprtk #define case_stmt(N) \ if (is_true(arg[(2 * N)].first)) { return arg[(2 * N) + 1].first->value(); } \ - struct switch_1 + struct switch_impl_1 { static inline T process(const arg_list_t& arg) { case_stmt(0) + assert(arg.size() == ((2 * 1) + 1)); + return arg.back().first->value(); } }; - struct switch_2 + struct switch_impl_2 { static inline T process(const arg_list_t& arg) { case_stmt(0) case_stmt(1) + assert(arg.size() == ((2 * 2) + 1)); + return arg.back().first->value(); } }; - struct switch_3 + struct switch_impl_3 { static inline T process(const arg_list_t& arg) { case_stmt(0) case_stmt(1) case_stmt(2) + assert(arg.size() == ((2 * 3) + 1)); + return arg.back().first->value(); } }; - struct switch_4 + struct switch_impl_4 { static inline T process(const arg_list_t& arg) { case_stmt(0) case_stmt(1) case_stmt(2) case_stmt(3) + assert(arg.size() == ((2 * 4) + 1)); + return arg.back().first->value(); } }; - struct switch_5 + struct switch_impl_5 { static inline T process(const arg_list_t& arg) { @@ -28162,11 +28701,13 @@ namespace exprtk case_stmt(2) case_stmt(3) case_stmt(4) + assert(arg.size() == ((2 * 5) + 1)); + return arg.back().first->value(); } }; - struct switch_6 + struct switch_impl_6 { static inline T process(const arg_list_t& arg) { @@ -28174,11 +28715,13 @@ namespace exprtk case_stmt(2) case_stmt(3) case_stmt(4) case_stmt(5) + assert(arg.size() == ((2 * 6) + 1)); + return arg.back().first->value(); } }; - struct switch_7 + struct switch_impl_7 { static inline T process(const arg_list_t& arg) { @@ -28187,6 +28730,8 @@ namespace exprtk case_stmt(4) case_stmt(5) case_stmt(6) + assert(arg.size() == ((2 * 7) + 1)); + return arg.back().first->value(); } }; @@ -28214,11 +28759,11 @@ namespace exprtk switch ((arg_list.size() - 1) / 2) { - #define case_stmt(N) \ - case N : \ - return node_allocator_-> \ - allocate >(arg_list); \ + #define case_stmt(N) \ + case N : \ + return node_allocator_-> \ + allocate >(arg_list); \ case_stmt(1) case_stmt(2) @@ -28249,47 +28794,47 @@ namespace exprtk return node_allocator_->allocate >(arg_list); } - #define unary_opr_switch_statements \ - case_stmt(details:: e_abs, details:: abs_op) \ - case_stmt(details:: e_acos, details:: acos_op) \ - case_stmt(details::e_acosh, details::acosh_op) \ - case_stmt(details:: e_asin, details:: asin_op) \ - case_stmt(details::e_asinh, details::asinh_op) \ - case_stmt(details:: e_atan, details:: atan_op) \ - case_stmt(details::e_atanh, details::atanh_op) \ - case_stmt(details:: e_ceil, details:: ceil_op) \ - case_stmt(details:: e_cos, details:: cos_op) \ - case_stmt(details:: e_cosh, details:: cosh_op) \ - case_stmt(details:: e_exp, details:: exp_op) \ - case_stmt(details::e_expm1, details::expm1_op) \ - case_stmt(details::e_floor, details::floor_op) \ - case_stmt(details:: e_log, details:: log_op) \ - case_stmt(details::e_log10, details::log10_op) \ - case_stmt(details:: e_log2, details:: log2_op) \ - case_stmt(details::e_log1p, details::log1p_op) \ - case_stmt(details:: e_neg, details:: neg_op) \ - case_stmt(details:: e_pos, details:: pos_op) \ - case_stmt(details::e_round, details::round_op) \ - case_stmt(details:: e_sin, details:: sin_op) \ - case_stmt(details:: e_sinc, details:: sinc_op) \ - case_stmt(details:: e_sinh, details:: sinh_op) \ - case_stmt(details:: e_sqrt, details:: sqrt_op) \ - case_stmt(details:: e_tan, details:: tan_op) \ - case_stmt(details:: e_tanh, details:: tanh_op) \ - case_stmt(details:: e_cot, details:: cot_op) \ - case_stmt(details:: e_sec, details:: sec_op) \ - case_stmt(details:: e_csc, details:: csc_op) \ - case_stmt(details:: e_r2d, details:: r2d_op) \ - case_stmt(details:: e_d2r, details:: d2r_op) \ - case_stmt(details:: e_d2g, details:: d2g_op) \ - case_stmt(details:: e_g2d, details:: g2d_op) \ - case_stmt(details:: e_notl, details:: notl_op) \ - case_stmt(details:: e_sgn, details:: sgn_op) \ - case_stmt(details:: e_erf, details:: erf_op) \ - case_stmt(details:: e_erfc, details:: erfc_op) \ - case_stmt(details:: e_ncdf, details:: ncdf_op) \ - case_stmt(details:: e_frac, details:: frac_op) \ - case_stmt(details::e_trunc, details::trunc_op) \ + #define unary_opr_switch_statements \ + case_stmt(details::e_abs , details::abs_op ) \ + case_stmt(details::e_acos , details::acos_op ) \ + case_stmt(details::e_acosh , details::acosh_op) \ + case_stmt(details::e_asin , details::asin_op ) \ + case_stmt(details::e_asinh , details::asinh_op) \ + case_stmt(details::e_atan , details::atan_op ) \ + case_stmt(details::e_atanh , details::atanh_op) \ + case_stmt(details::e_ceil , details::ceil_op ) \ + case_stmt(details::e_cos , details::cos_op ) \ + case_stmt(details::e_cosh , details::cosh_op ) \ + case_stmt(details::e_exp , details::exp_op ) \ + case_stmt(details::e_expm1 , details::expm1_op) \ + case_stmt(details::e_floor , details::floor_op) \ + case_stmt(details::e_log , details::log_op ) \ + case_stmt(details::e_log10 , details::log10_op) \ + case_stmt(details::e_log2 , details::log2_op ) \ + case_stmt(details::e_log1p , details::log1p_op) \ + case_stmt(details::e_neg , details::neg_op ) \ + case_stmt(details::e_pos , details::pos_op ) \ + case_stmt(details::e_round , details::round_op) \ + case_stmt(details::e_sin , details::sin_op ) \ + case_stmt(details::e_sinc , details::sinc_op ) \ + case_stmt(details::e_sinh , details::sinh_op ) \ + case_stmt(details::e_sqrt , details::sqrt_op ) \ + case_stmt(details::e_tan , details::tan_op ) \ + case_stmt(details::e_tanh , details::tanh_op ) \ + case_stmt(details::e_cot , details::cot_op ) \ + case_stmt(details::e_sec , details::sec_op ) \ + case_stmt(details::e_csc , details::csc_op ) \ + case_stmt(details::e_r2d , details::r2d_op ) \ + case_stmt(details::e_d2r , details::d2r_op ) \ + case_stmt(details::e_d2g , details::d2g_op ) \ + case_stmt(details::e_g2d , details::g2d_op ) \ + case_stmt(details::e_notl , details::notl_op ) \ + case_stmt(details::e_sgn , details::sgn_op ) \ + case_stmt(details::e_erf , details::erf_op ) \ + case_stmt(details::e_erfc , details::erfc_op ) \ + case_stmt(details::e_ncdf , details::ncdf_op ) \ + case_stmt(details::e_frac , details::frac_op ) \ + case_stmt(details::e_trunc , details::trunc_op) \ inline expression_node_ptr synthesize_uv_expression(const details::operator_type& operation, expression_node_ptr (&branch)[1]) @@ -28298,7 +28843,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(v); \ @@ -28313,7 +28858,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > > \ (operation, branch[0]); \ @@ -28329,7 +28874,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(branch[0]); \ @@ -28553,7 +29098,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : temp_node = node_allocator_-> \ allocate > > \ (arg_list); \ @@ -28595,7 +29140,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -28620,7 +29165,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list[0]); \ @@ -28667,7 +29212,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -28699,24 +29244,31 @@ namespace exprtk if (details::is_constant_node(result)) return result; else if (!all_nodes_valid(b)) + { + details::free_node(*node_allocator_,result); + std::fill_n(b, N, reinterpret_cast(0)); + return error_node(); + } else if (N != f->param_count) { - details::free_all_nodes(*node_allocator_,b); + details::free_node(*node_allocator_,result); + std::fill_n(b, N, reinterpret_cast(0)); return error_node(); } - function_N_node_t* func_node_ptr = static_cast(result); + function_N_node_t* func_node_ptr = reinterpret_cast(result); - if (func_node_ptr->init_branches(b)) - return result; - else + if (!func_node_ptr->init_branches(b)) { - details::free_all_nodes(*node_allocator_,b); + details::free_node(*node_allocator_,result); + std::fill_n(b, N, reinterpret_cast(0)); return error_node(); } + + return result; } } @@ -28889,8 +29441,8 @@ namespace exprtk } else { - details::free_node (*node_allocator_,result ); - details::free_all_nodes(*node_allocator_,arg_list); + details::free_node (*node_allocator_, result ); + details::free_all_nodes(*node_allocator_, arg_list); return error_node(); } @@ -29110,7 +29662,7 @@ namespace exprtk if (details::is_ivector_node(branch[1])) return synthesize_expression(operation, branch); - else + else return synthesize_expression(operation, branch); } else @@ -29130,16 +29682,16 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29150,16 +29702,16 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29170,16 +29722,16 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29190,16 +29742,16 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29212,16 +29764,16 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29230,16 +29782,16 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ - case_stmt(details::e_addass,details::add_op) - case_stmt(details::e_subass,details::sub_op) - case_stmt(details::e_mulass,details::mul_op) - case_stmt(details::e_divass,details::div_op) - case_stmt(details::e_modass,details::mod_op) + case_stmt(details::e_addass , details::add_op) + case_stmt(details::e_subass , details::sub_op) + case_stmt(details::e_mulass , details::mul_op) + case_stmt(details::e_divass , details::div_op) + case_stmt(details::e_modass , details::mod_op) #undef case_stmt default : return error_node(); } @@ -29272,26 +29824,26 @@ namespace exprtk const bool is_b0_ivec = details::is_ivector_node(branch[0]); const bool is_b1_ivec = details::is_ivector_node(branch[1]); - #define batch_eqineq_logic_case \ - case_stmt(details:: e_lt, details:: lt_op) \ - case_stmt(details:: e_lte, details:: lte_op) \ - case_stmt(details:: e_gt, details:: gt_op) \ - case_stmt(details:: e_gte, details:: gte_op) \ - case_stmt(details:: e_eq, details:: eq_op) \ - case_stmt(details:: e_ne, details:: ne_op) \ - case_stmt(details::e_equal, details::equal_op) \ - case_stmt(details:: e_and, details:: and_op) \ - case_stmt(details:: e_nand, details:: nand_op) \ - case_stmt(details:: e_or, details:: or_op) \ - case_stmt(details:: e_nor, details:: nor_op) \ - case_stmt(details:: e_xor, details:: xor_op) \ - case_stmt(details:: e_xnor, details:: xnor_op) \ + #define batch_eqineq_logic_case \ + case_stmt(details::e_lt , details::lt_op ) \ + case_stmt(details::e_lte , details::lte_op ) \ + case_stmt(details::e_gt , details::gt_op ) \ + case_stmt(details::e_gte , details::gte_op ) \ + case_stmt(details::e_eq , details::eq_op ) \ + case_stmt(details::e_ne , details::ne_op ) \ + case_stmt(details::e_equal , details::equal_op) \ + case_stmt(details::e_and , details::and_op ) \ + case_stmt(details::e_nand , details::nand_op ) \ + case_stmt(details::e_or , details::or_op ) \ + case_stmt(details::e_nor , details::nor_op ) \ + case_stmt(details::e_xor , details::xor_op ) \ + case_stmt(details::e_xnor , details::xnor_op ) \ if (is_b0_ivec && is_b1_ivec) { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29305,7 +29857,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29319,7 +29871,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29341,18 +29893,18 @@ namespace exprtk const bool is_b0_ivec = details::is_ivector_node(branch[0]); const bool is_b1_ivec = details::is_ivector_node(branch[1]); - #define vector_ops \ - case_stmt(details::e_add,details::add_op) \ - case_stmt(details::e_sub,details::sub_op) \ - case_stmt(details::e_mul,details::mul_op) \ - case_stmt(details::e_div,details::div_op) \ - case_stmt(details::e_mod,details::mod_op) \ + #define vector_ops \ + case_stmt(details::e_add , details::add_op) \ + case_stmt(details::e_sub , details::sub_op) \ + case_stmt(details::e_mul , details::mul_op) \ + case_stmt(details::e_div , details::div_op) \ + case_stmt(details::e_mod , details::mod_op) \ if (is_b0_ivec && is_b1_ivec) { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29367,7 +29919,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29382,7 +29934,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29492,8 +30044,8 @@ namespace exprtk if (result) { - free_node(*node_allocator_, branch[0]); - free_node(*node_allocator_, branch[1]); + details::free_node(*node_allocator_, branch[0]); + details::free_node(*node_allocator_, branch[1]); return result; } @@ -29515,27 +30067,27 @@ namespace exprtk } #endif - #define basic_opr_switch_statements \ - case_stmt(details::e_add, details::add_op) \ - case_stmt(details::e_sub, details::sub_op) \ - case_stmt(details::e_mul, details::mul_op) \ - case_stmt(details::e_div, details::div_op) \ - case_stmt(details::e_mod, details::mod_op) \ - case_stmt(details::e_pow, details::pow_op) \ + #define basic_opr_switch_statements \ + case_stmt(details::e_add , details::add_op) \ + case_stmt(details::e_sub , details::sub_op) \ + case_stmt(details::e_mul , details::mul_op) \ + case_stmt(details::e_div , details::div_op) \ + case_stmt(details::e_mod , details::mod_op) \ + case_stmt(details::e_pow , details::pow_op) \ - #define extended_opr_switch_statements \ - case_stmt(details:: e_lt, details:: lt_op) \ - case_stmt(details:: e_lte, details:: lte_op) \ - case_stmt(details:: e_gt, details:: gt_op) \ - case_stmt(details:: e_gte, details:: gte_op) \ - case_stmt(details:: e_eq, details:: eq_op) \ - case_stmt(details:: e_ne, details:: ne_op) \ - case_stmt(details:: e_and, details:: and_op) \ - case_stmt(details::e_nand, details::nand_op) \ - case_stmt(details:: e_or, details:: or_op) \ - case_stmt(details:: e_nor, details:: nor_op) \ - case_stmt(details:: e_xor, details:: xor_op) \ - case_stmt(details::e_xnor, details::xnor_op) \ + #define extended_opr_switch_statements \ + case_stmt(details::e_lt , details::lt_op ) \ + case_stmt(details::e_lte , details::lte_op ) \ + case_stmt(details::e_gt , details::gt_op ) \ + case_stmt(details::e_gte , details::gte_op ) \ + case_stmt(details::e_eq , details::eq_op ) \ + case_stmt(details::e_ne , details::ne_op ) \ + case_stmt(details::e_and , details::and_op ) \ + case_stmt(details::e_nand , details::nand_op) \ + case_stmt(details::e_or , details::or_op ) \ + case_stmt(details::e_nor , details::nor_op ) \ + case_stmt(details::e_xor , details::xor_op ) \ + case_stmt(details::e_xnor , details::xnor_op) \ #ifndef exprtk_disable_cardinal_pow_optimisation template class IPowNode> @@ -29766,7 +30318,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate > > \ (branch[0], branch[1]); \ @@ -29798,7 +30350,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } } @@ -29819,7 +30371,7 @@ namespace exprtk { const Type& v1 = static_cast(branch[1])->v(); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); switch (operation) { @@ -29841,7 +30393,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, branch[1]); \ @@ -29873,7 +30425,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return result; } @@ -29897,7 +30449,7 @@ namespace exprtk { const Type& v0 = static_cast(branch[0])->v(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); switch (operation) { @@ -29927,7 +30479,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], v); \ @@ -29948,17 +30500,17 @@ namespace exprtk { const Type c = static_cast*>(branch[0])->value(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } @@ -29973,8 +30525,8 @@ namespace exprtk // 1. (1 * (2 * (3 * (4 * (5 * (6 * (7 * (8 * (9 + x))))))))) --> 40320 * (9 + x) // 2. (1 + (2 + (3 + (4 + (5 + (6 + (7 + (8 + (9 + x))))))))) --> 45 + x if ( - (operation == details::e_mul) || - (operation == details::e_add) + (details::e_mul == operation) || + (details::e_add == operation) ) { details::cob_base_node* cobnode = static_cast*>(branch[1]); @@ -30039,7 +30591,7 @@ namespace exprtk default : return error_node(); } - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return new_cobnode; } @@ -30056,7 +30608,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } @@ -30065,7 +30617,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_tt > > \ (c, branch[1]); \ @@ -30090,13 +30642,13 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(std::numeric_limits::quiet_NaN()); } @@ -30111,8 +30663,8 @@ namespace exprtk // 1. (((((((((x + 9) * 8) * 7) * 6) * 5) * 4) * 3) * 2) * 1) --> (x + 9) * 40320 // 2. (((((((((x + 9) + 8) + 7) + 6) + 5) + 4) + 3) + 2) + 1) --> x + 45 if ( - (operation == details::e_mul) || - (operation == details::e_add) + (details::e_mul == operation) || + (details::e_add == operation) ) { details::boc_base_node* bocnode = static_cast*>(branch[0]); @@ -30184,7 +30736,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], c); \ @@ -30214,33 +30766,33 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(std::numeric_limits::quiet_NaN())); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } @@ -30283,13 +30835,13 @@ namespace exprtk template allocate_tt > > (cobnode->c() / c, cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } @@ -30302,27 +30854,27 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } @@ -30340,7 +30892,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == cobnode->operation()) @@ -30356,7 +30908,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == cobnode->operation()) @@ -30372,7 +30924,7 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == cobnode->operation()) @@ -30388,13 +30940,13 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30447,7 +30999,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } else if (details::e_sub == operation) { @@ -30469,7 +31021,7 @@ namespace exprtk if (result) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); } } @@ -30493,7 +31045,7 @@ namespace exprtk template allocate_tt > > (c - bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == bocnode->operation()) @@ -30504,7 +31056,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } else if (details::e_sub == operation) { @@ -30512,7 +31064,7 @@ namespace exprtk template allocate_tt > > (c + bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == bocnode->operation()) @@ -30528,7 +31080,7 @@ namespace exprtk template allocate_tt > > (c / bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == bocnode->operation()) @@ -30544,13 +31096,13 @@ namespace exprtk template allocate_tt > > (c * bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30593,7 +31145,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rr > > \ (v1, v2); \ @@ -30628,7 +31180,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (c, v); \ @@ -30672,7 +31224,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, c); \ @@ -30741,7 +31293,6 @@ namespace exprtk case details::e_sf##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ - #define case_stmt1(op) \ case details::e_sf4ext##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ @@ -30942,9 +31493,6 @@ namespace exprtk const details::operator_type o0 = vov->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); @@ -30956,7 +31504,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", v0, v1, v2, result); + template compile(expr_gen, "t/(t*t)", v0, v1, v2, result); exprtk_debug(("(v0 / v1) / v2 --> (vovov) v0 / (v1 * v2)\n")); @@ -30970,7 +31518,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -30979,7 +31531,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31005,9 +31558,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = vov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); @@ -31019,7 +31569,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", v0, v2, v1, result); + template compile(expr_gen, "(t*t)/t", v0, v2, v1, result); exprtk_debug(("v0 / (v1 / v2) --> (vovov) (v0 * v2) / v1\n")); @@ -31033,7 +31583,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31042,7 +31596,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31068,9 +31623,6 @@ namespace exprtk const details::operator_type o0 = vov->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31083,7 +31635,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", v0, v1, c, result); + template compile(expr_gen, "t/(t*t)", v0, v1, c, result); exprtk_debug(("(v0 / v1) / c --> (vovoc) v0 / (v1 * c)\n")); @@ -31097,7 +31649,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31106,7 +31662,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31132,9 +31689,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = voc->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); @@ -31146,7 +31700,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", v0, c, v1, result); + template compile(expr_gen, "(t*t)/t", v0, c, v1, result); exprtk_debug(("v0 / (v1 / c) --> (vocov) (v0 * c) / v1\n")); @@ -31160,7 +31714,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31169,7 +31727,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31195,9 +31754,6 @@ namespace exprtk const details::operator_type o0 = voc->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); @@ -31209,7 +31765,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", v0, v1, c, result); + template compile(expr_gen, "t/(t*t)", v0, v1, c, result); exprtk_debug(("(v0 / c) / v1 --> (vovoc) v0 / (v1 * c)\n")); @@ -31223,7 +31779,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31232,7 +31792,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31258,9 +31819,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = cov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[1]); expression_node_ptr result = error_node(); @@ -31286,7 +31844,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31295,7 +31857,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31321,9 +31884,6 @@ namespace exprtk const details::operator_type o0 = cov->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); expression_node_ptr result = error_node(); @@ -31349,7 +31909,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31358,7 +31922,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31384,9 +31949,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = vov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31413,7 +31975,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31421,7 +31987,9 @@ namespace exprtk return node_type::allocate(*(expr_gen.node_allocator_), c, v0, v1, f0, f1); } - static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) + static inline std::string id(expression_generator& expr_gen, + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31447,9 +32015,6 @@ namespace exprtk const details::operator_type o0 = cov->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31529,7 +32094,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31538,7 +32107,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31564,9 +32134,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = voc->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31646,7 +32213,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31655,7 +32226,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31667,7 +32239,9 @@ namespace exprtk struct synthesize_cocov_expression0 { typedef typename cocov_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (c0 o0 c1) o1 (v) - Not possible. return error_node(); @@ -31691,9 +32265,6 @@ namespace exprtk const details::operator_type o0 = operation; const details::operator_type o1 = cov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31773,7 +32344,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31781,7 +32356,9 @@ namespace exprtk return node_type::allocate(*(expr_gen.node_allocator_), c0, c1, v, f0, f1); } - static inline std::string id(expression_generator& expr_gen, const details::operator_type o0, const details::operator_type o1) + static inline std::string id(expression_generator& expr_gen, + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "t" << expr_gen.to_str(o0) @@ -31807,9 +32384,6 @@ namespace exprtk const details::operator_type o0 = voc->operation(); const details::operator_type o1 = operation; - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31897,7 +32471,11 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -31906,7 +32484,8 @@ namespace exprtk } static inline std::string id(expression_generator& expr_gen, - const details::operator_type o0, const details::operator_type o1) + const details::operator_type o0, + const details::operator_type o1) { return details::build_string() << "(t" << expr_gen.to_str(o0) @@ -31919,7 +32498,9 @@ namespace exprtk { typedef typename vococ_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (v) o0 (c0 o1 c1) - Not possible. exprtk_debug(("(v) o0 (c0 o1 c1) - Not possible.\n")); @@ -31951,10 +32532,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = vov1->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -31967,7 +32544,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, v3, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, v3, result); exprtk_debug(("(v0 / v1) * (v2 / v3) --> (vovovov) (v0 * v2) / (v1 * v3)\n")); @@ -31978,7 +32555,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v3, v1, v2, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v3, v1, v2, result); exprtk_debug(("(v0 / v1) / (v2 / v3) --> (vovovov) (v0 * v3) / (v1 * v2)\n")); @@ -31989,7 +32566,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t+t)*(t/t)", v0, v1, v3, v2, result); + template compile(expr_gen, "(t+t)*(t/t)", v0, v1, v3, v2, result); exprtk_debug(("(v0 + v1) / (v2 / v3) --> (vovovov) (v0 + v1) * (v3 / v2)\n")); @@ -32000,7 +32577,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t-t)*(t/t)", v0, v1, v3, v2, result); + template compile(expr_gen, "(t-t)*(t/t)", v0, v1, v3, v2, result); exprtk_debug(("(v0 - v1) / (v2 / v3) --> (vovovov) (v0 - v1) * (v3 / v2)\n")); @@ -32011,7 +32588,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "((t*t)*t)/t", v0, v1, v3, v2, result); + template compile(expr_gen, "((t*t)*t)/t", v0, v1, v3, v2, result); exprtk_debug(("(v0 * v1) / (v2 / v3) --> (vovovov) ((v0 * v1) * v3) / v2\n")); @@ -32025,7 +32602,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32072,10 +32654,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = voc->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32088,7 +32666,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); exprtk_debug(("(v0 / v1) * (v2 / c) --> (vovovoc) (v0 * v2) / (v1 * c)\n")); @@ -32099,7 +32677,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); exprtk_debug(("(v0 / v1) / (v2 / c) --> (vocovov) (v0 * c) / (v1 * v2)\n")); @@ -32113,7 +32691,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32160,10 +32743,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = cov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32176,7 +32755,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, c, v1, v2, result); exprtk_debug(("(v0 / v1) * (c / v2) --> (vocovov) (v0 * c) / (v1 * v2)\n")); @@ -32187,7 +32766,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, v1, c, result); exprtk_debug(("(v0 / v1) / (c / v2) --> (vovovoc) (v0 * v2) / (v1 * c)\n")); @@ -32201,7 +32780,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32248,10 +32832,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = vov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32264,7 +32844,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v1, c, v2, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v1, c, v2, result); exprtk_debug(("(v0 / c) * (v1 / v2) --> (vovocov) (v0 * v1) / (c * v2)\n")); @@ -32275,7 +32855,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", v0, v2, c, v1, result); + template compile(expr_gen, "(t*t)/(t*t)", v0, v2, c, v1, result); exprtk_debug(("(v0 / c) / (v1 / v2) --> (vovocov) (v0 * v2) / (c * v1)\n")); @@ -32289,7 +32869,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32336,10 +32921,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = vov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32352,7 +32933,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", c, v1, v0, v2, result); + template compile(expr_gen, "(t*t)/(t*t)", c, v1, v0, v2, result); exprtk_debug(("(c / v0) * (v1 / v2) --> (covovov) (c * v1) / (v0 * v2)\n")); @@ -32363,7 +32944,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)/(t*t)", c, v2, v0, v1, result); + template compile(expr_gen, "(t*t)/(t*t)", c, v2, v0, v1, result); exprtk_debug(("(c / v0) / (v1 / v2) --> (covovov) (c * v2) / (v0 * v1)\n")); @@ -32377,7 +32958,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32424,10 +33010,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = cov1->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32440,7 +33022,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 + v0) + (c1 + v1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -32451,7 +33033,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 + v0) - (c1 + v1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -32462,7 +33044,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t-t)+t", (c0 - c1), v0, v1, result); + template compile(expr_gen, "(t-t)+t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 - v0) - (c1 - v1) --> (covov) (c0 - c1) - v0 + v1\n")); @@ -32473,7 +33055,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -32484,7 +33066,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -32495,7 +33077,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); + template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 / v0) * (c1 / v1) --> (covov) (c0 * c1) / (v0 * v1)\n")); @@ -32506,7 +33088,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 / c1), v1, v0, result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v1, v0, result); exprtk_debug(("(c0 / v0) / (c1 / v1) --> (covov) ((c0 / c1) * v1) / v0\n")); @@ -32517,7 +33099,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t*(t*t)", (c0 / c1), v0, v1, result); + template compile(expr_gen, "t*(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -32528,7 +33110,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); + template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (c1 * v1) --> (covov) (c0 / c1) / (v0 * v1)\n")); @@ -32570,7 +33152,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32617,10 +33204,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = voc1->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32633,7 +33216,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(v0 + c0) + (v1 + c1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -32644,7 +33227,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(v0 + c0) - (v1 + c1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -32655,7 +33238,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", (c1 - c0), v0, v1, result); + template compile(expr_gen, "(t+t)-t", (c1 - c0), v0, v1, result); exprtk_debug(("(v0 - c0) - (v1 - c1) --> (covov) (c1 - c0) + v0 - v1\n")); @@ -32666,7 +33249,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -32677,7 +33260,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -32688,7 +33271,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", Type(1) / (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) * (v1 / c1) --> (covov) (1 / (c0 * c1)) * v0 * v1\n")); @@ -32699,7 +33282,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); exprtk_debug(("(v0 / c0) / (v1 / c1) --> (covov) ((c1 / c0) * v0) / v1\n")); @@ -32710,7 +33293,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t*(t/t)", (c0 * c1), v0, v1, result); + template compile(expr_gen, "t*(t/t)", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1)\n")); @@ -32721,7 +33304,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t*(t/t)", Type(1) / (c0 * c1), v0, v1, result); + template compile(expr_gen, "t*(t/t)", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) / (v1 * c1) --> (covov) (1 / (c0 * c1)) * v0 / v1\n")); @@ -32732,7 +33315,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)*(t+t)", v0, T(1) / c0, v1, c1, result); + template compile(expr_gen, "(t*t)*(t+t)", v0, T(1) / c0, v1, c1, result); exprtk_debug(("(v0 / c0) * (v1 + c1) --> (vocovoc) (v0 * (1 / c0)) * (v1 + c1)\n")); @@ -32743,7 +33326,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf4ext_expression:: - template compile(expr_gen, "(t*t)*(t-t)", v0, T(1) / c0, v1, c1, result); + template compile(expr_gen, "(t*t)*(t-t)", v0, T(1) / c0, v1, c1, result); exprtk_debug(("(v0 / c0) * (v1 - c1) --> (vocovoc) (v0 * (1 / c0)) * (v1 - c1)\n")); @@ -32771,7 +33354,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, specfunc, c0, v0, v1, result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(v0 * c) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -32799,7 +33382,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, specfunc, v0, v1, c0, result); + template compile(expr_gen, specfunc, v0, v1, c0, result); exprtk_debug(("(v0 / c) +/- (v1 / c) --> (vovoc) (v0 +/- v1) / c\n")); @@ -32813,7 +33396,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -32860,10 +33448,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = voc->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -32876,7 +33460,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 + v0) + (v1 + c1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -32887,7 +33471,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(c0 + v0) - (v1 + c1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -32898,7 +33482,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t-(t+t)", (c0 + c1), v0, v1, result); + template compile(expr_gen, "t-(t+t)", (c0 + c1), v0, v1, result); exprtk_debug(("(c0 - v0) - (v1 - c1) --> (covov) (c0 + c1) - v0 - v1\n")); @@ -32909,7 +33493,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) * (v1 * c1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -32920,7 +33504,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (v1 * c1) --> (covov) (c0 / c1) * (v0 / v1)\n")); @@ -32931,7 +33515,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t*(t/t)", (c0 / c1), v1, v0, result); + template compile(expr_gen, "t*(t/t)", (c0 / c1), v1, v0, result); exprtk_debug(("(c0 / v0) * (v1 / c1) --> (covov) (c0 / c1) * (v1 / v0)\n")); @@ -32942,7 +33526,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); + template compile(expr_gen, "t/(t*t)", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (v1 / c1) --> (covov) (c0 * c1) / (v0 * v1)\n")); @@ -32953,7 +33537,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c0 * c1), v0, v1, result); exprtk_debug(("(c0 * v0) / (v1 / c1) --> (covov) (c0 * c1) * (v0 / v1)\n")); @@ -32964,7 +33548,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); + template compile(expr_gen, "t/(t*t)", (c0 / c1), v0, v1, result); exprtk_debug(("(c0 / v0) / (v1 * c1) --> (covov) (c0 / c1) / (v0 * v1)\n")); @@ -32992,7 +33576,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc, c0, v0, v1, result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(c * v0) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -33006,7 +33590,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -33053,10 +33642,6 @@ namespace exprtk const details::operator_type o1 = operation; const details::operator_type o2 = cov->operation(); - binary_functor_t f0 = reinterpret_cast(0); - binary_functor_t f1 = reinterpret_cast(0); - binary_functor_t f2 = reinterpret_cast(0); - details::free_node(*(expr_gen.node_allocator_),branch[0]); details::free_node(*(expr_gen.node_allocator_),branch[1]); @@ -33069,7 +33654,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); + template compile(expr_gen, "(t+t)+t", (c0 + c1), v0, v1, result); exprtk_debug(("(v0 + c0) + (c1 + v1) --> (covov) (c0 + c1) + v0 + v1\n")); @@ -33080,7 +33665,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); + template compile(expr_gen, "(t+t)-t", (c0 - c1), v0, v1, result); exprtk_debug(("(v0 + c0) - (c1 + v1) --> (covov) (c0 - c1) + v0 - v1\n")); @@ -33091,7 +33676,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t+t)-t", v0, v1, (c1 + c0), result); + template compile(expr_gen, "(t+t)-t", v0, v1, (c1 + c0), result); exprtk_debug(("(v0 - c0) - (c1 - v1) --> (vovoc) v0 + v1 - (c1 + c0)\n")); @@ -33102,7 +33687,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", (c0 * c1), v0, v1, result); exprtk_debug(("(v0 * c0) * (c1 * v1) --> (covov) (c0 * c1) * v0 * v1\n")); @@ -33113,7 +33698,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (c1 * v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -33124,7 +33709,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); + template compile(expr_gen, "(t*t)/t", (c1 / c0), v0, v1, result); exprtk_debug(("(v0 / c0) * (c1 / v1) --> (covov) (c1 / c0) * (v0 / v1)\n")); @@ -33135,7 +33720,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", (c0 / c1), v0, v1, result); + template compile(expr_gen, "(t*t)*t", (c0 / c1), v0, v1, result); exprtk_debug(("(v0 * c0) / (c1 / v1) --> (covov) (c0 / c1) * (v0 * v1)\n")); @@ -33146,7 +33731,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)/t", Type(1) / (c0 * c1), v0, v1, result); + template compile(expr_gen, "(t*t)/t", Type(1) / (c0 * c1), v0, v1, result); exprtk_debug(("(v0 / c0) / (c1 * v1) --> (covov) (1 / (c0 * c1)) * (v0 / v1)\n")); @@ -33157,7 +33742,7 @@ namespace exprtk { const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, "(t*t)*t", v0, v1, Type(1) / (c0 * c1), result); + template compile(expr_gen, "(t*t)*t", v0, v1, Type(1) / (c0 * c1), result); exprtk_debug(("(v0 / c0) / (c1 / v1) --> (vovoc) (v0 * v1) * (1 / (c0 * c1))\n")); @@ -33184,7 +33769,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen, specfunc, c0, v0, v1, result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(v0 * c) +/- (c * v1) --> (covov) c * (v0 +/- v1)\n")); @@ -33198,7 +33783,12 @@ namespace exprtk if (synthesis_result) return result; - else if (!expr_gen.valid_operator(o0,f0)) + + binary_functor_t f0 = reinterpret_cast(0); + binary_functor_t f1 = reinterpret_cast(0); + binary_functor_t f2 = reinterpret_cast(0); + + if (!expr_gen.valid_operator(o0,f0)) return error_node(); else if (!expr_gen.valid_operator(o1,f1)) return error_node(); @@ -33254,14 +33844,18 @@ namespace exprtk expression_node_ptr result = error_node(); - if (synthesize_sf4ext_expression::template compile(expr_gen,id(expr_gen,o0,o1,o2),v0,v1,v2,v3,result)) + const bool synthesis_result = + synthesize_sf4ext_expression::template compile + (expr_gen,id(expr_gen, o0, o1, o2), v0, v1, v2, v3, result); + + if (synthesis_result) return result; else if (!expr_gen.valid_operator(o0,f0)) return error_node(); exprtk_debug(("v0 o0 (v1 o1 (v2 o2 v3))\n")); - return node_type::allocate(*(expr_gen.node_allocator_),v0,v1,v2,v3,f0,f1,f2); + return node_type::allocate(*(expr_gen.node_allocator_), v0, v1, v2, v3, f0, f1, f2); } static inline std::string id(expression_generator& expr_gen, @@ -34245,7 +34839,9 @@ namespace exprtk struct synthesize_vococov_expression2 { typedef typename vococov_t::type2 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // v0 o0 ((c0 o1 c1) o2 v1) - Not possible exprtk_debug(("v0 o0 ((c0 o1 c1) o2 v1) - Not possible\n")); @@ -34253,7 +34849,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35287,7 +35885,9 @@ namespace exprtk struct synthesize_vococov_expression4 { typedef typename vococov_t::type4 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // ((v0 o0 (c0 o1 c1)) o2 v1) - Not possible exprtk_debug(("((v0 o0 (c0 o1 c1)) o2 v1) - Not possible\n")); @@ -35295,7 +35895,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35378,16 +35980,16 @@ namespace exprtk #ifndef exprtk_disable_string_capabilities - #define string_opr_switch_statements \ - case_stmt(details:: e_lt ,details:: lt_op) \ - case_stmt(details:: e_lte ,details:: lte_op) \ - case_stmt(details:: e_gt ,details:: gt_op) \ - case_stmt(details:: e_gte ,details:: gte_op) \ - case_stmt(details:: e_eq ,details:: eq_op) \ - case_stmt(details:: e_ne ,details:: ne_op) \ - case_stmt(details::e_in ,details:: in_op) \ - case_stmt(details::e_like ,details:: like_op) \ - case_stmt(details::e_ilike,details::ilike_op) \ + #define string_opr_switch_statements \ + case_stmt(details::e_lt , details::lt_op ) \ + case_stmt(details::e_lte , details::lte_op ) \ + case_stmt(details::e_gt , details::gt_op ) \ + case_stmt(details::e_gte , details::gte_op ) \ + case_stmt(details::e_eq , details::eq_op ) \ + case_stmt(details::e_ne , details::ne_op ) \ + case_stmt(details::e_in , details::in_op ) \ + case_stmt(details::e_like , details::like_op ) \ + case_stmt(details::e_ilike , details::ilike_op) \ template inline expression_node_ptr synthesize_str_xrox_expression_impl(const details::operator_type& opr, @@ -35396,7 +35998,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp0); \ @@ -35414,7 +36016,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp1); \ @@ -35432,7 +36034,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tttt >,T0,T1> \ (s0, s1, rp0, rp1); \ @@ -35448,7 +36050,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tt >,T0,T1>(s0, s1); \ @@ -35474,7 +36076,7 @@ namespace exprtk static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -35487,7 +36089,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35500,7 +36102,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35534,7 +36136,7 @@ namespace exprtk inline expression_node_ptr synthesize_csos_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { std::string s0 = static_cast*>(branch[0])->str(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); details::free_node(*node_allocator_,branch[0]); @@ -35543,9 +36145,9 @@ namespace exprtk inline expression_node_ptr synthesize_csosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); - range_t rp1 = static_cast*> (branch[1])->range(); + std::string s0 = static_cast*>(branch[0])->str (); + std::string& s1 = static_cast* >(branch[1])->ref (); + range_t rp1 = static_cast* >(branch[1])->range(); static_cast*>(branch[1])->range_ref().clear(); @@ -35557,9 +36159,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -35571,9 +36173,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*> (branch[0])->range_ref().clear(); @@ -35618,14 +36220,14 @@ namespace exprtk inline expression_node_ptr synthesize_csocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - const std::string s0 = static_cast*> (branch[0])->str (); + const std::string s0 = static_cast* >(branch[0])->str (); std::string s1 = static_cast*>(branch[1])->str (); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35633,12 +36235,12 @@ namespace exprtk inline expression_node_ptr synthesize_csros_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -35646,15 +36248,15 @@ namespace exprtk inline expression_node_ptr synthesize_csrosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); const range_t rp0 = static_cast*>(branch[0])->range(); - const range_t rp1 = static_cast*> (branch[1])->range(); + const range_t rp1 = static_cast* >(branch[1])->range(); static_cast*>(branch[0])->range_ref().clear(); static_cast*> (branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } @@ -35662,7 +36264,7 @@ namespace exprtk inline expression_node_ptr synthesize_csrocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - const std::string s1 = static_cast*> (branch[1])->str (); + const std::string s1 = static_cast* >(branch[1])->str (); const range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -35691,7 +36293,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt > > \ (opr, branch[0], branch[1]); \ @@ -35753,28 +36355,28 @@ namespace exprtk } else if (b0_is_s) { - if (b1_is_s ) return synthesize_sos_expression (opr,branch); + if (b1_is_s ) return synthesize_sos_expression (opr,branch); else if (b1_is_cs ) return synthesize_socs_expression (opr,branch); else if (b1_is_sr ) return synthesize_sosr_expression (opr,branch); else if (b1_is_csr) return synthesize_socsr_expression (opr,branch); } else if (b0_is_cs) { - if (b1_is_s ) return synthesize_csos_expression (opr,branch); + if (b1_is_s ) return synthesize_csos_expression (opr,branch); else if (b1_is_cs ) return synthesize_csocs_expression (opr,branch); else if (b1_is_sr ) return synthesize_csosr_expression (opr,branch); else if (b1_is_csr) return synthesize_csocsr_expression(opr,branch); } else if (b0_is_sr) { - if (b1_is_s ) return synthesize_sros_expression (opr,branch); + if (b1_is_s ) return synthesize_sros_expression (opr,branch); else if (b1_is_sr ) return synthesize_srosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_srocs_expression (opr,branch); else if (b1_is_csr) return synthesize_srocsr_expression(opr,branch); } else if (b0_is_csr) { - if (b1_is_s ) return synthesize_csros_expression (opr,branch); + if (b1_is_s ) return synthesize_csros_expression (opr,branch); else if (b1_is_sr ) return synthesize_csrosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_csrocs_expression (opr,branch); else if (b1_is_csr) return synthesize_csrocsr_expression(opr,branch); @@ -35838,7 +36440,7 @@ namespace exprtk ) { std::string s0 = static_cast*>(branch[0])->str(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); typedef typename details::sosos_node > inrange_t; @@ -35854,9 +36456,9 @@ namespace exprtk details::is_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); std::string s1 = static_cast*>(branch[1])->str(); - std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); + std::string& s2 = static_cast* >(branch[2])->ref(); typedef typename details::sosos_node > inrange_t; @@ -35870,8 +36472,8 @@ namespace exprtk details::is_const_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); typedef typename details::sosos_node > inrange_t; @@ -35887,8 +36489,8 @@ namespace exprtk ) { std::string s0 = static_cast*>(branch[0])->str(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); - std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); + std::string& s2 = static_cast* >(branch[2])->ref(); typedef typename details::sosos_node > inrange_t; @@ -36089,7 +36691,7 @@ namespace exprtk sf3_map_t* sf3_map_; sf4_map_t* sf4_map_; parser_t* parser_; - }; + }; // class expression_generator inline void set_error(const parser_error::type& error_type) { @@ -36179,48 +36781,48 @@ namespace exprtk inline void load_unary_operations_map(unary_op_map_t& m) { - #define register_unary_op(Op,UnaryFunctor) \ + #define register_unary_op(Op, UnaryFunctor) \ m.insert(std::make_pair(Op,UnaryFunctor::process)); \ - register_unary_op(details:: e_abs, details:: abs_op) - register_unary_op(details:: e_acos, details:: acos_op) - register_unary_op(details::e_acosh, details::acosh_op) - register_unary_op(details:: e_asin, details:: asin_op) - register_unary_op(details::e_asinh, details::asinh_op) - register_unary_op(details::e_atanh, details::atanh_op) - register_unary_op(details:: e_ceil, details:: ceil_op) - register_unary_op(details:: e_cos, details:: cos_op) - register_unary_op(details:: e_cosh, details:: cosh_op) - register_unary_op(details:: e_exp, details:: exp_op) - register_unary_op(details::e_expm1, details::expm1_op) - register_unary_op(details::e_floor, details::floor_op) - register_unary_op(details:: e_log, details:: log_op) - register_unary_op(details::e_log10, details::log10_op) - register_unary_op(details:: e_log2, details:: log2_op) - register_unary_op(details::e_log1p, details::log1p_op) - register_unary_op(details:: e_neg, details:: neg_op) - register_unary_op(details:: e_pos, details:: pos_op) - register_unary_op(details::e_round, details::round_op) - register_unary_op(details:: e_sin, details:: sin_op) - register_unary_op(details:: e_sinc, details:: sinc_op) - register_unary_op(details:: e_sinh, details:: sinh_op) - register_unary_op(details:: e_sqrt, details:: sqrt_op) - register_unary_op(details:: e_tan, details:: tan_op) - register_unary_op(details:: e_tanh, details:: tanh_op) - register_unary_op(details:: e_cot, details:: cot_op) - register_unary_op(details:: e_sec, details:: sec_op) - register_unary_op(details:: e_csc, details:: csc_op) - register_unary_op(details:: e_r2d, details:: r2d_op) - register_unary_op(details:: e_d2r, details:: d2r_op) - register_unary_op(details:: e_d2g, details:: d2g_op) - register_unary_op(details:: e_g2d, details:: g2d_op) - register_unary_op(details:: e_notl, details:: notl_op) - register_unary_op(details:: e_sgn, details:: sgn_op) - register_unary_op(details:: e_erf, details:: erf_op) - register_unary_op(details:: e_erfc, details:: erfc_op) - register_unary_op(details:: e_ncdf, details:: ncdf_op) - register_unary_op(details:: e_frac, details:: frac_op) - register_unary_op(details::e_trunc, details::trunc_op) + register_unary_op(details::e_abs , details::abs_op ) + register_unary_op(details::e_acos , details::acos_op ) + register_unary_op(details::e_acosh , details::acosh_op) + register_unary_op(details::e_asin , details::asin_op ) + register_unary_op(details::e_asinh , details::asinh_op) + register_unary_op(details::e_atanh , details::atanh_op) + register_unary_op(details::e_ceil , details::ceil_op ) + register_unary_op(details::e_cos , details::cos_op ) + register_unary_op(details::e_cosh , details::cosh_op ) + register_unary_op(details::e_exp , details::exp_op ) + register_unary_op(details::e_expm1 , details::expm1_op) + register_unary_op(details::e_floor , details::floor_op) + register_unary_op(details::e_log , details::log_op ) + register_unary_op(details::e_log10 , details::log10_op) + register_unary_op(details::e_log2 , details::log2_op ) + register_unary_op(details::e_log1p , details::log1p_op) + register_unary_op(details::e_neg , details::neg_op ) + register_unary_op(details::e_pos , details::pos_op ) + register_unary_op(details::e_round , details::round_op) + register_unary_op(details::e_sin , details::sin_op ) + register_unary_op(details::e_sinc , details::sinc_op ) + register_unary_op(details::e_sinh , details::sinh_op ) + register_unary_op(details::e_sqrt , details::sqrt_op ) + register_unary_op(details::e_tan , details::tan_op ) + register_unary_op(details::e_tanh , details::tanh_op ) + register_unary_op(details::e_cot , details::cot_op ) + register_unary_op(details::e_sec , details::sec_op ) + register_unary_op(details::e_csc , details::csc_op ) + register_unary_op(details::e_r2d , details::r2d_op ) + register_unary_op(details::e_d2r , details::d2r_op ) + register_unary_op(details::e_d2g , details::d2g_op ) + register_unary_op(details::e_g2d , details::g2d_op ) + register_unary_op(details::e_notl , details::notl_op ) + register_unary_op(details::e_sgn , details::sgn_op ) + register_unary_op(details::e_erf , details::erf_op ) + register_unary_op(details::e_erfc , details::erfc_op ) + register_unary_op(details::e_ncdf , details::ncdf_op ) + register_unary_op(details::e_frac , details::frac_op ) + register_unary_op(details::e_trunc , details::trunc_op) #undef register_unary_op } @@ -36228,27 +36830,27 @@ namespace exprtk { typedef typename binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(Op,BinaryFunctor::process)); \ - register_binary_op(details:: e_add, details:: add_op) - register_binary_op(details:: e_sub, details:: sub_op) - register_binary_op(details:: e_mul, details:: mul_op) - register_binary_op(details:: e_div, details:: div_op) - register_binary_op(details:: e_mod, details:: mod_op) - register_binary_op(details:: e_pow, details:: pow_op) - register_binary_op(details:: e_lt, details:: lt_op) - register_binary_op(details:: e_lte, details:: lte_op) - register_binary_op(details:: e_gt, details:: gt_op) - register_binary_op(details:: e_gte, details:: gte_op) - register_binary_op(details:: e_eq, details:: eq_op) - register_binary_op(details:: e_ne, details:: ne_op) - register_binary_op(details:: e_and, details:: and_op) - register_binary_op(details::e_nand, details::nand_op) - register_binary_op(details:: e_or, details:: or_op) - register_binary_op(details:: e_nor, details:: nor_op) - register_binary_op(details:: e_xor, details:: xor_op) - register_binary_op(details::e_xnor, details::xnor_op) + register_binary_op(details::e_add , details::add_op ) + register_binary_op(details::e_sub , details::sub_op ) + register_binary_op(details::e_mul , details::mul_op ) + register_binary_op(details::e_div , details::div_op ) + register_binary_op(details::e_mod , details::mod_op ) + register_binary_op(details::e_pow , details::pow_op ) + register_binary_op(details::e_lt , details::lt_op ) + register_binary_op(details::e_lte , details::lte_op ) + register_binary_op(details::e_gt , details::gt_op ) + register_binary_op(details::e_gte , details::gte_op ) + register_binary_op(details::e_eq , details::eq_op ) + register_binary_op(details::e_ne , details::ne_op ) + register_binary_op(details::e_and , details::and_op ) + register_binary_op(details::e_nand , details::nand_op) + register_binary_op(details::e_or , details::or_op ) + register_binary_op(details::e_nor , details::nor_op ) + register_binary_op(details::e_xor , details::xor_op ) + register_binary_op(details::e_xnor , details::xnor_op) #undef register_binary_op } @@ -36256,27 +36858,27 @@ namespace exprtk { typedef typename inv_binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(BinaryFunctor::process,Op)); \ - register_binary_op(details:: e_add, details:: add_op) - register_binary_op(details:: e_sub, details:: sub_op) - register_binary_op(details:: e_mul, details:: mul_op) - register_binary_op(details:: e_div, details:: div_op) - register_binary_op(details:: e_mod, details:: mod_op) - register_binary_op(details:: e_pow, details:: pow_op) - register_binary_op(details:: e_lt, details:: lt_op) - register_binary_op(details:: e_lte, details:: lte_op) - register_binary_op(details:: e_gt, details:: gt_op) - register_binary_op(details:: e_gte, details:: gte_op) - register_binary_op(details:: e_eq, details:: eq_op) - register_binary_op(details:: e_ne, details:: ne_op) - register_binary_op(details:: e_and, details:: and_op) - register_binary_op(details::e_nand, details::nand_op) - register_binary_op(details:: e_or, details:: or_op) - register_binary_op(details:: e_nor, details:: nor_op) - register_binary_op(details:: e_xor, details:: xor_op) - register_binary_op(details::e_xnor, details::xnor_op) + register_binary_op(details::e_add , details::add_op ) + register_binary_op(details::e_sub , details::sub_op ) + register_binary_op(details::e_mul , details::mul_op ) + register_binary_op(details::e_div , details::div_op ) + register_binary_op(details::e_mod , details::mod_op ) + register_binary_op(details::e_pow , details::pow_op ) + register_binary_op(details::e_lt , details::lt_op ) + register_binary_op(details::e_lte , details::lte_op ) + register_binary_op(details::e_gt , details::gt_op ) + register_binary_op(details::e_gte , details::gte_op ) + register_binary_op(details::e_eq , details::eq_op ) + register_binary_op(details::e_ne , details::ne_op ) + register_binary_op(details::e_and , details::and_op ) + register_binary_op(details::e_nand , details::nand_op) + register_binary_op(details::e_or , details::or_op ) + register_binary_op(details::e_nor , details::nor_op ) + register_binary_op(details::e_xor , details::xor_op ) + register_binary_op(details::e_xnor , details::xnor_op) #undef register_binary_op } @@ -36369,8 +36971,8 @@ namespace exprtk private: - parser(const parser&); - parser& operator=(const parser&); + parser(const parser&) exprtk_delete; + parser& operator=(const parser&) exprtk_delete; settings_store settings_; expression_generator expression_generator_; @@ -36408,7 +37010,7 @@ namespace exprtk template friend void details::disable_type_checking(ParserType& p); - }; + }; // class parser namespace details { @@ -36416,8 +37018,8 @@ namespace exprtk struct collector_helper { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; typedef typename parser_t::unknown_symbol_resolver usr_t; @@ -36670,9 +37272,9 @@ namespace exprtk x = x_init + _2h; const T y0 = e.value(); - x = x_init + h; + x = x_init + h; const T y1 = e.value(); - x = x_init - h; + x = x_init - h; const T y2 = e.value(); x = x_init - _2h; const T y3 = e.value(); @@ -36692,9 +37294,9 @@ namespace exprtk const T y = e.value(); x = x_init + _2h; const T y0 = e.value(); - x = x_init + h; + x = x_init + h; const T y1 = e.value(); - x = x_init - h; + x = x_init - h; const T y2 = e.value(); x = x_init - _2h; const T y3 = e.value(); @@ -36713,9 +37315,9 @@ namespace exprtk x = x_init + _2h; const T y0 = e.value(); - x = x_init + h; + x = x_init + h; const T y1 = e.value(); - x = x_init - h; + x = x_init - h; const T y2 = e.value(); x = x_init - _2h; const T y3 = e.value(); @@ -37081,8 +37683,7 @@ namespace exprtk disable_has_side_effects(*this); } - virtual ~polynomial() - {} + virtual ~polynomial() {} #define poly_rtrn(NN) \ return (NN != N) ? std::numeric_limits::quiet_NaN() : @@ -37102,47 +37703,60 @@ namespace exprtk poly_rtrn(3) (poly_impl::evaluate(x, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(4) (poly_impl::evaluate(x, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(5) (poly_impl::evaluate(x, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(6) (poly_impl::evaluate(x, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(7) (poly_impl::evaluate(x, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, + const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(8) (poly_impl::evaluate(x, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, + const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(9) (poly_impl::evaluate(x, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, + const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(10) (poly_impl::evaluate(x, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, + const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(11) (poly_impl::evaluate(x, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, + const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(12) (poly_impl::evaluate(x, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } @@ -37186,15 +37800,15 @@ namespace exprtk function(const std::string& name, const std::string& expression) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) {} function(const std::string& name, const std::string& expression, const std::string& v0) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) { v_.push_back(v0); } @@ -37202,8 +37816,8 @@ namespace exprtk function(const std::string& name, const std::string& expression, const std::string& v0, const std::string& v1) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) { v_.push_back(v0); v_.push_back(v1); } @@ -37212,8 +37826,8 @@ namespace exprtk const std::string& expression, const std::string& v0, const std::string& v1, const std::string& v2) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) { v_.push_back(v0); v_.push_back(v1); v_.push_back(v2); @@ -37223,8 +37837,8 @@ namespace exprtk const std::string& expression, const std::string& v0, const std::string& v1, const std::string& v2, const std::string& v3) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) { v_.push_back(v0); v_.push_back(v1); v_.push_back(v2); v_.push_back(v3); @@ -37235,8 +37849,8 @@ namespace exprtk const std::string& v0, const std::string& v1, const std::string& v2, const std::string& v3, const std::string& v4) - : name_(name), - expression_(expression) + : name_(name) + , expression_(expression) { v_.push_back(v0); v_.push_back(v1); v_.push_back(v2); v_.push_back(v3); @@ -37280,50 +37894,52 @@ namespace exprtk using exprtk::ifunction::operator(); base_func(const std::size_t& pc = 0) - : exprtk::ifunction(pc), - local_var_stack_size(0), - stack_depth(0) + : exprtk::ifunction(pc) + , local_var_stack_size(0) + , stack_depth(0) { v.resize(pc); } - virtual ~base_func() - {} + virtual ~base_func() {} + + #define assign(Index) \ + (*v[Index]) = v##Index; \ inline void update(const T& v0) { - (*v[0]) = v0; + assign(0) } inline void update(const T& v0, const T& v1) { - (*v[0]) = v0; (*v[1]) = v1; + assign(0) assign(1) } inline void update(const T& v0, const T& v1, const T& v2) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; + assign(0) assign(1) + assign(2) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; + assign(0) assign(1) + assign(2) assign(3) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; + assign(0) assign(1) + assign(2) assign(3) + assign(4) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; (*v[5]) = v5; + assign(0) assign(1) + assign(2) assign(3) + assign(4) assign(5) } inline function_t& setup(expression_t& expr) @@ -37501,15 +38117,23 @@ namespace exprtk template struct scoped_bft { - scoped_bft(BaseFuncType& bft) : bft_(bft) { bft_.pre (); } - ~scoped_bft() { bft_.post(); } + explicit scoped_bft(BaseFuncType& bft) + : bft_(bft) + { + bft_.pre (); + } + + ~scoped_bft() + { + bft_.post(); + } BaseFuncType& bft_; private: - scoped_bft(scoped_bft&); - scoped_bft& operator=(scoped_bft&); + scoped_bft(const scoped_bft&) exprtk_delete; + scoped_bft& operator=(const scoped_bft&) exprtk_delete; }; struct func_1param : public base_func @@ -37654,7 +38278,7 @@ namespace exprtk remove(name, var_list.size()); } - if (compile_expression(name,expression,var_list)) + if (compile_expression(name, expression, var_list)) { const std::size_t n = var_list.size(); @@ -37675,15 +38299,15 @@ namespace exprtk function_compositor() : parser_(settings_t::compile_all_opts + - settings_t::e_disable_zero_return), - fp_map_(7) + settings_t::e_disable_zero_return) + , fp_map_(7) {} function_compositor(const symbol_table_t& st) - : symbol_table_(st), - parser_(settings_t::compile_all_opts + - settings_t::e_disable_zero_return), - fp_map_(7) + : symbol_table_(st) + , parser_(settings_t::compile_all_opts + + settings_t::e_disable_zero_return) + , fp_map_(7) {} ~function_compositor() @@ -37696,6 +38320,11 @@ namespace exprtk return symbol_table_; } + inline const symbol_table_t& symbol_table() const + { + return symbol_table_; + } + inline void add_auxiliary_symtab(symbol_table_t& symtab) { auxiliary_symtab_list_.push_back(&symtab); @@ -37906,7 +38535,7 @@ namespace exprtk std::map expr_map_; std::vector fp_map_; std::vector auxiliary_symtab_list_; - }; + }; // class function_compositor template inline bool pgo_primer() @@ -38076,7 +38705,7 @@ namespace exprtk { const T v = T(123.456 + i); - if (details::is_true(details::numeric::nequal(details::numeric::fast_exp::result(v),details::numeric::pow(v,T( 1))))) + if (details::is_true(details::numeric::nequal(details::numeric::fast_exp::result(v),details::numeric::pow(v,T(1))))) return false; #define else_stmt(N) \ @@ -38157,6 +38786,7 @@ namespace exprtk { start_time_.tv_sec = 0; start_time_.tv_usec = 0; + stop_time_.tv_sec = 0; stop_time_.tv_usec = 0; } @@ -38215,6 +38845,17 @@ namespace exprtk #endif }; + template + struct type_defs + { + typedef symbol_table symbol_table_t; + typedef expression expression_t; + typedef parser parser_t; + typedef parser_error::type error_t; + typedef function_compositor compositor_t; + typedef typename compositor_t::function function_t; + }; + } // namespace exprtk #ifndef exprtk_disable_rtl_io @@ -38339,7 +38980,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -38348,7 +38989,7 @@ namespace exprtk return false; \ } \ - exprtk_register_function("print" , p) + exprtk_register_function("print" , p ) exprtk_register_function("println", pl) #undef exprtk_register_function @@ -38378,9 +39019,9 @@ namespace exprtk struct file_descriptor { file_descriptor(const std::string& fname, const std::string& access) - : stream_ptr(0), - mode(get_file_mode(access)), - file_name(fname) + : stream_ptr(0) + , mode(get_file_mode(access)) + , file_name(fname) {} void* stream_ptr; @@ -38562,11 +39203,13 @@ namespace exprtk template file_descriptor* make_handle(T v) { - file_descriptor* fd = reinterpret_cast(0); + details::file_descriptor* fd = reinterpret_cast(0); + + const std::size_t fd_size = sizeof(details::file_descriptor*); std::memcpy(reinterpret_cast(&fd), reinterpret_cast(&v), - sizeof(fd)); + fd_size); return fd; } @@ -38625,9 +39268,11 @@ namespace exprtk { T t = T(0); + const std::size_t fd_size = sizeof(details::file_descriptor*); + std::memcpy(reinterpret_cast(&t ), reinterpret_cast(&fd), - sizeof(fd)); + fd_size); return t; } else @@ -38682,32 +39327,32 @@ namespace exprtk { details::file_descriptor* fd = details::make_handle(scalar_t(parameters[0])()); - std::size_t amount = 0; - switch (ps_index) { case 0 : { const string_t buffer(parameters[1]); - amount = buffer.size(); + const std::size_t amount = buffer.size(); return T(fd->write(buffer, amount) ? 1 : 0); } case 1 : { const string_t buffer(parameters[1]); - amount = std::min(buffer.size(), + const std::size_t amount = + std::min(buffer.size(), static_cast(scalar_t(parameters[2])())); return T(fd->write(buffer, amount) ? 1 : 0); } case 2 : { const vector_t vec(parameters[1]); - amount = vec.size(); + const std::size_t amount = vec.size(); return T(fd->write(vec, amount) ? 1 : 0); } case 3 : { const vector_t vec(parameters[1]); - amount = std::min(vec.size(), + const std::size_t amount = + std::min(vec.size(), static_cast(scalar_t(parameters[2])())); return T(fd->write(vec, amount) ? 1 : 0); } @@ -38739,32 +39384,32 @@ namespace exprtk { details::file_descriptor* fd = details::make_handle(scalar_t(parameters[0])()); - std::size_t amount = 0; - switch (ps_index) { case 0 : { string_t buffer(parameters[1]); - amount = buffer.size(); + const std::size_t amount = buffer.size(); return T(fd->read(buffer,amount) ? 1 : 0); } case 1 : { string_t buffer(parameters[1]); - amount = std::min(buffer.size(), + const std::size_t amount = + std::min(buffer.size(), static_cast(scalar_t(parameters[2])())); return T(fd->read(buffer,amount) ? 1 : 0); } case 2 : { vector_t vec(parameters[1]); - amount = vec.size(); + const std::size_t amount = vec.size(); return T(fd->read(vec,amount) ? 1 : 0); } case 3 : { vector_t vec(parameters[1]); - amount = std::min(vec.size(), + const std::size_t amount = + std::min(vec.size(), static_cast(scalar_t(parameters[2])())); return T(fd->read(vec,amount) ? 1 : 0); } @@ -38828,7 +39473,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -38837,12 +39482,12 @@ namespace exprtk return false; \ } \ - exprtk_register_function("open" ,o) - exprtk_register_function("close" ,c) - exprtk_register_function("write" ,w) - exprtk_register_function("read" ,r) - exprtk_register_function("getline",g) - exprtk_register_function("eof" ,e) + exprtk_register_function("open" , o) + exprtk_register_function("close" , c) + exprtk_register_function("write" , w) + exprtk_register_function("read" , r) + exprtk_register_function("getline" , g) + exprtk_register_function("eof" , e) #undef exprtk_register_function return true; @@ -39193,7 +39838,10 @@ namespace exprtk const std::size_t n = std::min(xr1 - xr0 + 1, yr1 - yr0 + 1); - std::copy(x.begin() + xr0, x.begin() + xr0 + n, y.begin() + yr0); + std::copy( + x.begin() + xr0, + x.begin() + xr0 + n, + y.begin() + yr0); return T(n); } @@ -39340,7 +39988,7 @@ namespace exprtk ) return T(0); - const std::size_t dist = r1 - r0 + 1; + const std::size_t dist = r1 - r0 + 1; if (n > dist) return T(0); @@ -39398,7 +40046,7 @@ namespace exprtk ) return T(0); - const std::size_t dist = r1 - r0 + 1; + const std::size_t dist = r1 - r0 + 1; if (n > dist) return T(0); @@ -39468,9 +40116,15 @@ namespace exprtk } if (ascending) - std::sort(vec.begin() + r0, vec.begin() + r1 + 1, std::less ()); + std::sort( + vec.begin() + r0, + vec.begin() + r1 + 1, + std::less()); else - std::sort(vec.begin() + r0, vec.begin() + r1 + 1, std::greater()); + std::sort( + vec.begin() + r0, + vec.begin() + r1 + 1, + std::greater()); return T(1); } @@ -39512,7 +40166,10 @@ namespace exprtk if ((1 == ps_index) && !helper::load_vector_range::process(parameters, r0, r1, 2, 3, 0)) return std::numeric_limits::quiet_NaN(); - std::nth_element(vec.begin() + r0, vec.begin() + r0 + n , vec.begin() + r1 + 1); + std::nth_element( + vec.begin() + r0, + vec.begin() + r0 + n , + vec.begin() + r1 + 1); return T(1); } @@ -39977,7 +40634,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -39986,29 +40643,29 @@ namespace exprtk return false; \ } \ - exprtk_register_function("all_true" ,at) - exprtk_register_function("all_false" ,af) - exprtk_register_function("any_true" ,nt) - exprtk_register_function("any_false" ,nf) - exprtk_register_function("count" , c) - exprtk_register_function("copy" ,cp) - exprtk_register_function("rotate_left" ,rl) - exprtk_register_function("rol" ,rl) - exprtk_register_function("rotate_right" ,rr) - exprtk_register_function("ror" ,rr) - exprtk_register_function("shftl" ,sl) - exprtk_register_function("shftr" ,sr) - exprtk_register_function("sort" ,st) - exprtk_register_function("nth_element" ,ne) - exprtk_register_function("iota" ,ia) - exprtk_register_function("sumk" ,sk) - exprtk_register_function("axpy" ,b1_axpy) - exprtk_register_function("axpby" ,b1_axpby) - exprtk_register_function("axpyz" ,b1_axpyz) - exprtk_register_function("axpbyz",b1_axpbyz) - exprtk_register_function("axpbz" ,b1_axpbz) - exprtk_register_function("dot" ,dt) - exprtk_register_function("dotk" ,dtk) + exprtk_register_function("all_true" , at ) + exprtk_register_function("all_false" , af ) + exprtk_register_function("any_true" , nt ) + exprtk_register_function("any_false" , nf ) + exprtk_register_function("count" , c ) + exprtk_register_function("copy" , cp ) + exprtk_register_function("rotate_left" , rl ) + exprtk_register_function("rol" , rl ) + exprtk_register_function("rotate_right" , rr ) + exprtk_register_function("ror" , rr ) + exprtk_register_function("shftl" , sl ) + exprtk_register_function("shftr" , sr ) + exprtk_register_function("sort" , st ) + exprtk_register_function("nth_element" , ne ) + exprtk_register_function("iota" , ia ) + exprtk_register_function("sumk" , sk ) + exprtk_register_function("axpy" , b1_axpy ) + exprtk_register_function("axpby" , b1_axpby ) + exprtk_register_function("axpyz" , b1_axpyz ) + exprtk_register_function("axpbyz" , b1_axpbyz) + exprtk_register_function("axpbz" , b1_axpbz ) + exprtk_register_function("dot" , dt ) + exprtk_register_function("dotk" , dtk ) #undef exprtk_register_function return true; @@ -40025,11 +40682,11 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.71828182845904523536028747135" - "2662497757247093699959574966967" - "6277240766303535475945713821785" - "2516642742746639193200305992181"; - static const char* date = "20200101"; + static const char* version = "2.718281828459045235360287471352" + "66249775724709369995957496696762" + "77240766303535475945713821785251" + "66427427466391932003059921817413"; + static const char* date = "20210101"; static inline std::string data() { @@ -40057,6 +40714,18 @@ namespace exprtk #undef exprtk_disable_fallthrough_end #endif + #ifdef exprtk_override + #undef exprtk_override + #endif + + #ifdef exprtk_final + #undef exprtk_final + #endif + + #ifdef exprtk_delete + #undef exprtk_delete + #endif + } // namespace exprtk #endif diff --git a/exprtk_benchmark.cpp b/exprtk_benchmark.cpp index 8e9c5fa..637def5 100644 --- a/exprtk_benchmark.cpp +++ b/exprtk_benchmark.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * ExprTk vs Native Benchmarks * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -150,7 +150,7 @@ template bool run_parse_benchmark(exprtk::symbol_table& symbol_table) { static const std::size_t rounds = 100000; - exprtk::parser parser; + exprtk::parser parser; exprtk::expression expression; expression.register_symbol_table(symbol_table); @@ -288,7 +288,7 @@ struct native } }; -void pgo_primer(); +double pgo_primer(); void perform_file_based_benchmark(const std::string& file_name, const std::size_t& rounds = 100000); int main(int argc, char* argv[]) @@ -359,7 +359,7 @@ int main(int argc, char* argv[]) return 0; } -void pgo_primer() +double pgo_primer() { exprtk::pgo_primer(); @@ -394,6 +394,8 @@ void pgo_primer() total += native::func16(x,y); } } + + return total; } std::size_t load_expression_file(const std::string& file_name, std::deque& expression_list) @@ -431,8 +433,8 @@ void perform_file_based_benchmark(const std::string& file_name, const std::size_ } typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::deque expression_list; diff --git a/exprtk_functional_test.txt b/exprtk_functional_test.txt index ee6dfe1..9d9f8e9 100644 --- a/exprtk_functional_test.txt +++ b/exprtk_functional_test.txt @@ -8093,4 +8093,214 @@ equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := 2 * abs((1 + xx) + (yy equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := abs((xx + 1) + (yy + 1)) * 2; sum(xx) == 10^6},true) equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := abs((1 + xx) + (1 + yy)) * 2; sum(xx) == 10^6},true) equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := abs((xx + 1) + (1 + yy)) * 2; sum(xx) == 10^6},true) -equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := abs((1 + xx) + (yy + 1)) * 2; sum(xx) == 10^6},true) \ No newline at end of file +equal(~{var xx[10^5] := [-3]; var yy[10^5] := [-4]; xx := abs((1 + xx) + (yy + 1)) * 2; sum(xx) == 10^6},true) +equal('abcd' like 'abcd*' ,true ) +equal('abcd' like 'abc*' ,true ) +equal('abcd' like 'ab*' ,true ) +equal('abcd' like 'a*' ,true ) +equal('abcd' like 'abc?' ,true ) +equal('a' like 'a*' ,true ) +equal('ab' like 'a*' ,true ) +equal('abcd' like 'abcd*' ,true ) +equal('' like '' ,true ) +equal('abcd' like 'abcd' ,true ) +equal('abcd' like 'abc*' ,true ) +equal('abcd' like '*bcd' ,true ) +equal('abcd' like 'abc?' ,true ) +equal('abcd' like '?bcd' ,true ) +equal('abcd' like 'ab?d' ,true ) +equal('abcd' like 'ab*d' ,true ) +equal('abcd' like 'a?cd' ,true ) +equal('abcd' like 'a*cd' ,true ) +equal('abcd' like 'a??d' ,true ) +equal('abcd' like 'a*?d' ,true ) +equal('abcd' like '*bc*' ,true ) +equal('abcd' like '?bc?' ,true ) +equal('abcd' like '????' ,true ) +equal('abcd' like 'a???' ,true ) +equal('abcd' like 'ab??' ,true ) +equal('abcd' like 'abc?' ,true ) +equal('abcd' like '???d' ,true ) +equal('abcd' like '??cd' ,true ) +equal('abcd' like '?bcd' ,true ) +equal('abcd' like '?b?d' ,true ) +equal('abcd' like 'a?c?' ,true ) +equal('abcd' like 'a??d' ,true ) +equal('abcd' like '?bc?' ,true ) +equal('abcd' like 'ab**' ,true ) +equal('abcd' like 'ab*?' ,true ) +equal('abcd' like 'a***' ,true ) +equal('abcd' like '**cd' ,true ) +equal('abcd' like '*?cd' ,true ) +equal('abcd' like '***d' ,true ) +equal('abcd' like '?*?d' ,true ) +equal('abcd' like '?*?d' ,true ) +equal('abcd' like '*bc*' ,true ) +equal('abcd' like '*bc?' ,true ) +equal('abcd' like '*b??' ,true ) +equal('abcd' like '?bc*' ,true ) +equal('abcd' like '??c*' ,true ) +equal('abcd' like '*b?*' ,true ) +equal('abcd' like '*b*d' ,true ) +equal('abcd' like 'a*c*' ,true ) +equal('abcd' like '?*cd' ,true ) +equal('abcd' like 'ab?*' ,true ) +equal('abcd' like 'ab*?' ,true ) +equal('abcd' like 'a?*d' ,true ) +equal('ab' like 'a*' ,true ) +equal('ab' like 'a?' ,true ) +equal('a' like 'a*' ,true ) +equal('xalabcd' like '*abcd*' ,true ) +equal('xablabcd' like '*abcd*' ,true ) +equal('xabclabcd' like '*abcd*' ,true ) +equal('aaaaa' like '*aa?' ,true ) +equal('abcd' ilike 'abcd*' ,true ) +equal('abcd' ilike 'abc*' ,true ) +equal('abcd' ilike 'ab*' ,true ) +equal('abcd' ilike 'a*' ,true ) +equal('abcd' ilike 'abc?' ,true ) +equal('a' ilike 'a*' ,true ) +equal('ab' ilike 'a*' ,true ) +equal('abcd' ilike 'abcd*' ,true ) +equal('' ilike '' ,true ) +equal('abcd' ilike 'abcd' ,true ) +equal('abcd' ilike 'abc*' ,true ) +equal('abcd' ilike '*bcd' ,true ) +equal('abcd' ilike 'abc?' ,true ) +equal('abcd' ilike '?bcd' ,true ) +equal('abcd' ilike 'ab?d' ,true ) +equal('abcd' ilike 'ab*d' ,true ) +equal('abcd' ilike 'a?cd' ,true ) +equal('abcd' ilike 'a*cd' ,true ) +equal('abcd' ilike 'a??d' ,true ) +equal('abcd' ilike 'a*?d' ,true ) +equal('abcd' ilike '*bc*' ,true ) +equal('abcd' ilike '?bc?' ,true ) +equal('abcd' ilike '????' ,true ) +equal('abcd' ilike 'a???' ,true ) +equal('abcd' ilike 'ab??' ,true ) +equal('abcd' ilike 'abc?' ,true ) +equal('abcd' ilike '???d' ,true ) +equal('abcd' ilike '??cd' ,true ) +equal('abcd' ilike '?bcd' ,true ) +equal('abcd' ilike '?b?d' ,true ) +equal('abcd' ilike 'a?c?' ,true ) +equal('abcd' ilike 'a??d' ,true ) +equal('abcd' ilike '?bc?' ,true ) +equal('abcd' ilike 'ab**' ,true ) +equal('abcd' ilike 'ab*?' ,true ) +equal('abcd' ilike 'a***' ,true ) +equal('abcd' ilike '**cd' ,true ) +equal('abcd' ilike '*?cd' ,true ) +equal('abcd' ilike '***d' ,true ) +equal('abcd' ilike '?*?d' ,true ) +equal('abcd' ilike '?*?d' ,true ) +equal('abcd' ilike '*bc*' ,true ) +equal('abcd' ilike '*bc?' ,true ) +equal('abcd' ilike '*b??' ,true ) +equal('abcd' ilike '?bc*' ,true ) +equal('abcd' ilike '??c*' ,true ) +equal('abcd' ilike '*b?*' ,true ) +equal('abcd' ilike '*b*d' ,true ) +equal('abcd' ilike 'a*c*' ,true ) +equal('abcd' ilike '?*cd' ,true ) +equal('abcd' ilike 'ab?*' ,true ) +equal('abcd' ilike 'ab*?' ,true ) +equal('abcd' ilike 'a?*d' ,true ) +equal('ab' ilike 'a*' ,true ) +equal('ab' ilike 'a?' ,true ) +equal('a' ilike 'a*' ,true ) +equal('xalabcd' ilike '*abcd*',true ) +equal('xablabcd' ilike '*abcd*',true ) +equal('xabclabcd' ilike '*abcd*',true ) +equal('aaaaa' ilike '*aa?' ,true ) +equal('abcd' like 'abcd?' ,false) +equal('abcd' like 'abc??' ,false) +equal('abcd' like 'ab???' ,false) +equal('abcd' like 'a????' ,false) +equal('abcd' like '?????' ,false) +equal('a' like 'a?' ,false) +equal('abcd' like 'xyzw' ,false) +equal('abcd' like 'xyz' ,false) +equal('abc' like 'xyzw' ,false) +equal('abcd' like 'ab?' ,false) +equal('abcd' like 'a?' ,false) +equal('abcd' ilike 'abcd?' ,false) +equal('abcd' ilike 'abc??' ,false) +equal('abcd' ilike 'ab???' ,false) +equal('abcd' ilike 'a????' ,false) +equal('abcd' ilike '?????' ,false) +equal('a' ilike 'a?' ,false) +equal('abcd' ilike 'xyzw' ,false) +equal('abcd' ilike 'xyz' ,false) +equal('abc' ilike 'xyzw' ,false) +equal('abcd' ilike 'ab?' ,false) +equal('abcd' ilike 'a?' ,false) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n < m) 'n < m'; else 'n >= m'; }; (s == 'n < m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n > m) 'n <= m'; else 'n > m'; }; (s == 'n > m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n < m) 'n < m'; else 'n >' + '= m'; }; (s == 'n < m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n < m) 'n ' + '< m'; else 'n >= m'; }; (s == 'n < m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n > m) 'n <= m'; else 'n ' + '> m'; }; (s == 'n > m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; if (n > m) 'n <' + '= m'; else 'n > m'; }; (s == 'n > m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; var r0 := 'n < m'; var r1 := 'n >= m'; if (n < m) r0; else r1; }; (s == 'n < m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; var r0 := 'n < m'; var r1 := 'n >= m'; if (n < m) r0 + ''; else r1 + ''; }; (s == 'n < m')}) +equal(true, ~{var s := ~{var n := 1; var m := 2; var r0 := 'n < m'; var r1 := 'n >= m'; if (n < m) '' + r0; else '' + r1; }; (s == 'n < m')}) +equal(111,~{var n:=1; switch { case n > 0: 111; default: 222; }}) +equal(222,~{var n:=0; switch { case n > 0: 111; default: 222; }}) +equal(111,~{var n:=0; switch { case true : 111; default: 222; }}) +equal(222,~{var n:=0; switch { case false: 111; default: 222; }}) +equal(111,~{var n:=1; switch { default: 222; case n > 0: 111; }}) +equal(222,~{var n:=0; switch { default: 222; case n > 0: 111; }}) +equal(111,~{var n:=0; switch { default: 222; case true : 111; }}) +equal(222,~{var n:=0; switch { default: 222; case false: 111; }}) +equal(111,~{var n:=1; switch { case n == 1: 111; case n == 2: 222; default: 333; }}) +equal(111,~{var n:=1; switch { case n == 1: 111; default: 333; case n == 2: 222; }}) +equal(111,~{var n:=1; switch { default: 333; case n == 1: 111; case n == 2: 222; }}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 < 2, v0, v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 > 2, v0, v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 < 2, v0 - v1, v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 > 2, v0 - v1, v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; if (x_ < y_, v0, v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; if (x_ > y_, v0, v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; if (x_ < y_, v0 - v1, v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; if (x_ > y_, v0 - v1, v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 < 2, v0, v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 > 2, v0, v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 < 2, v0 - v1, v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 > 2, v0 - v1, v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; if (x_ < y_, v0, v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; if (x_ > y_, v0, v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; if (x_ < y_, v0 - v1, v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; if (x_ > y_, v0 - v1, v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 < 2) v0; else v1;) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 > 2) v0; else v1;) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 < 2) v0 - v1; else v1 - v0;) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 > 2) v0 - v1; else v1 - v0;) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; (if (x_ < y_) v0; else v1;) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; (if (x_ > y_) v0; else v1;) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; (if (x_ < y_) v0 - v1; else v1 - v0;) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; (if (x_ > y_) v0 - v1; else v1 - v0;) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 < 2) v0; else v1;) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 > 2) v0; else v1;) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 < 2) v0 - v1; else v1 - v0;) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 > 2) v0 - v1; else v1 - v0;) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; (if (x_ < y_) v0; else v1;) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; (if (x_ > y_) v0; else v1;) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; (if (x_ < y_) v0 - v1; else v1 - v0;) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; (if (x_ > y_) v0 - v1; else v1 - v0;) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; ((1 < 2) ? v0 : v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; ((1 > 2) ? v0 : v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; ((1 < 2) ? v0 - v1 : v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; ((1 > 2) ? v0 - v1 : v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; ((x_ < y_) ? v0 : v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; ((x_ > y_) ? v0 : v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; ((x_ < y_) ? v0 - v1 : v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x_ := 1; var y_ := 2; ((x_ > y_) ? v0 - v1 : v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; ((1 < 2) ? v0 : v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; ((1 > 2) ? v0 : v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; ((1 < 2) ? v0 - v1 : v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; ((1 > 2) ? v0 - v1 : v1 - v0) == (v1 - v0)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; ((x_ < y_) ? v0 : v1) == v0}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; ((x_ > y_) ? v0 : v1) == v1}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; ((x_ < y_) ? v0 - v1 : v1 - v0) == (v0 - v1)}) +equal(true,~{var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x_ := 1; var y_ := 2; ((x_ > y_) ? v0 - v1 : v1 - v0) == (v1 - v0)}) \ No newline at end of file diff --git a/exprtk_simple_example_01.cpp b/exprtk_simple_example_01.cpp index 80eafe1..f1fb113 100644 --- a/exprtk_simple_example_01.cpp +++ b/exprtk_simple_example_01.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 1 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void trig_function() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expression_string = "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)"; diff --git a/exprtk_simple_example_02.cpp b/exprtk_simple_example_02.cpp index 56b9c9b..ef7f70c 100644 --- a/exprtk_simple_example_02.cpp +++ b/exprtk_simple_example_02.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 2 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void square_wave() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expr_string = "a*(4/pi)*" diff --git a/exprtk_simple_example_03.cpp b/exprtk_simple_example_03.cpp index 8e5a164..0de505e 100644 --- a/exprtk_simple_example_03.cpp +++ b/exprtk_simple_example_03.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 3 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void polynomial() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expression_string = "25x^5 - 35x^4 - 15x^3 + 40x^2 - 15x + 1"; diff --git a/exprtk_simple_example_04.cpp b/exprtk_simple_example_04.cpp index aca7014..0b25ec5 100644 --- a/exprtk_simple_example_04.cpp +++ b/exprtk_simple_example_04.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 4 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -25,11 +25,11 @@ template void fibonacci() { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; compositor_t compositor; diff --git a/exprtk_simple_example_05.cpp b/exprtk_simple_example_05.cpp index 50d7987..4450fb2 100644 --- a/exprtk_simple_example_05.cpp +++ b/exprtk_simple_example_05.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 5 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -47,8 +47,8 @@ template void custom_function() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expression_string = "myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))"; diff --git a/exprtk_simple_example_06.cpp b/exprtk_simple_example_06.cpp index 0af6f8b..2475905 100644 --- a/exprtk_simple_example_06.cpp +++ b/exprtk_simple_example_06.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 6 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void vector_function() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expression_string = " for (var i := 0; i < min(x[],y[],z[]); i += 1) " diff --git a/exprtk_simple_example_07.cpp b/exprtk_simple_example_07.cpp index bdf3c3b..ac7d7e2 100644 --- a/exprtk_simple_example_07.cpp +++ b/exprtk_simple_example_07.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 7 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void logic() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string expression_string = "not(A and B) or C"; diff --git a/exprtk_simple_example_08.cpp b/exprtk_simple_example_08.cpp index 4565098..f2b76c7 100644 --- a/exprtk_simple_example_08.cpp +++ b/exprtk_simple_example_08.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 8 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -25,12 +25,12 @@ template void composite() { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::parser_error::type err_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::parser_error::type error_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; compositor_t compositor; @@ -65,7 +65,7 @@ void composite() for (std::size_t i = 0; i < parser.error_count(); ++i) { - const err_t error = parser.get_error(i); + const error_t error = parser.get_error(i); printf("Error: %02d Position: %02d Type: [%14s] Msg: %s\tExpression: %s\n", static_cast(i), diff --git a/exprtk_simple_example_09.cpp b/exprtk_simple_example_09.cpp index b11f193..3a3892c 100644 --- a/exprtk_simple_example_09.cpp +++ b/exprtk_simple_example_09.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 9 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -25,11 +25,11 @@ template void primes() { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; T x = T(0); diff --git a/exprtk_simple_example_10.cpp b/exprtk_simple_example_10.cpp index 13728da..7b11d7b 100644 --- a/exprtk_simple_example_10.cpp +++ b/exprtk_simple_example_10.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 10 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,11 +26,11 @@ template void newton_sqrt() { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; T x = T(0); diff --git a/exprtk_simple_example_11.cpp b/exprtk_simple_example_11.cpp index 454c8f0..e2ccf35 100644 --- a/exprtk_simple_example_11.cpp +++ b/exprtk_simple_example_11.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 11 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void square_wave2() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string wave_program = " var r := 0; " diff --git a/exprtk_simple_example_12.cpp b/exprtk_simple_example_12.cpp index ce398bd..d1adb77 100644 --- a/exprtk_simple_example_12.cpp +++ b/exprtk_simple_example_12.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 12 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void bubble_sort() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string bubblesort_program = " var upper_bound := v[]; " diff --git a/exprtk_simple_example_13.cpp b/exprtk_simple_example_13.cpp index e1922e8..32b6976 100644 --- a/exprtk_simple_example_13.cpp +++ b/exprtk_simple_example_13.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 13 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -28,8 +28,8 @@ template void savitzky_golay_filter() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string sgfilter_program = " var weight[9] := " @@ -69,15 +69,15 @@ void savitzky_golay_filter() // Generate a signal with noise. for (T t = T(-5); t <= T(+5); t += T(10.0 / n)) { - T noise = T(0.5 * (rand() / (RAND_MAX + 1.0) - 0.5)); + const T noise = T(0.5 * (rand() / (RAND_MAX + 1.0) - 0.5)); v_in.push_back(sin(2.0 * pi * t) + noise); } v_out.resize(v_in.size()); symbol_table_t symbol_table; - symbol_table.add_vector("v_in" , v_in); - symbol_table.add_vector("v_out",v_out); + symbol_table.add_vector("v_in" , v_in ); + symbol_table.add_vector("v_out", v_out); expression_t expression; expression.register_symbol_table(symbol_table); diff --git a/exprtk_simple_example_14.cpp b/exprtk_simple_example_14.cpp index bc508a2..5ff9d79 100644 --- a/exprtk_simple_example_14.cpp +++ b/exprtk_simple_example_14.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 14 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,7 +26,7 @@ template void stddev_example() { typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::parser parser_t; const std::string stddev_program = " var x[25] := { " diff --git a/exprtk_simple_example_15.cpp b/exprtk_simple_example_15.cpp index f7364fd..852a643 100644 --- a/exprtk_simple_example_15.cpp +++ b/exprtk_simple_example_15.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 15 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void black_scholes_merton_model() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string bsm_model_program = " var d1 := (log(s / x) + (r + v^2 / 2) * t) / (v * sqrt(t)); " @@ -67,7 +67,7 @@ void black_scholes_merton_model() { callput_flag = "call"; - T bsm = expression.value(); + const T bsm = expression.value(); printf("BSM(%s,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f) = %10.6f\n", callput_flag.c_str(), @@ -78,7 +78,7 @@ void black_scholes_merton_model() { callput_flag = "put"; - T bsm = expression.value(); + const T bsm = expression.value(); printf("BSM(%s,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f) = %10.6f\n", callput_flag.c_str(), diff --git a/exprtk_simple_example_16.cpp b/exprtk_simple_example_16.cpp index cd76f84..06ee39c 100644 --- a/exprtk_simple_example_16.cpp +++ b/exprtk_simple_example_16.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 16 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -27,8 +27,8 @@ template void linear_least_squares() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string linear_least_squares_program = " if (x[] == y[]) " @@ -55,11 +55,11 @@ void linear_least_squares() T rmse = T(0); symbol_table_t symbol_table; - symbol_table.add_variable("alpha",alpha); - symbol_table.add_variable("beta" ,beta ); - symbol_table.add_variable("rmse" ,rmse ); - symbol_table.add_vector ("x" ,x ); - symbol_table.add_vector ("y" ,y ); + symbol_table.add_variable("alpha", alpha); + symbol_table.add_variable("beta" , beta ); + symbol_table.add_variable("rmse" , rmse ); + symbol_table.add_vector ("x" , x ); + symbol_table.add_vector ("y" , y ); expression_t expression; expression.register_symbol_table(symbol_table); @@ -69,10 +69,10 @@ void linear_least_squares() expression.value(); - printf("alpha: %15.12f\n",alpha); - printf("beta: %15.12f\n",beta ); - printf("rmse: %15.12f\n",rmse ); - printf("y = %15.12fx + %15.12f\n",beta,alpha); + printf("alpha: %15.12f\n", alpha); + printf("beta: %15.12f\n", beta ); + printf("rmse: %15.12f\n", rmse ); + printf("y = %15.12fx + %15.12f\n", beta, alpha); } int main() diff --git a/exprtk_simple_example_17.cpp b/exprtk_simple_example_17.cpp index 50263aa..d141204 100644 --- a/exprtk_simple_example_17.cpp +++ b/exprtk_simple_example_17.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 17 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -44,8 +44,8 @@ template void monte_carlo_pi() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string monte_carlo_pi_program = " var experiments[5 * 10^7] := [(rnd_01^2 + rnd_01^2) <= 1]; " diff --git a/exprtk_simple_example_18.cpp b/exprtk_simple_example_18.cpp index 4fabc72..84f4575 100644 --- a/exprtk_simple_example_18.cpp +++ b/exprtk_simple_example_18.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 18 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -26,8 +26,8 @@ template void file_io() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string fileio_program = " var file_name := 'file.txt'; " diff --git a/exprtk_simple_example_19.cpp b/exprtk_simple_example_19.cpp index 5d0fc20..753022f 100644 --- a/exprtk_simple_example_19.cpp +++ b/exprtk_simple_example_19.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Simple Example 19 * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -81,8 +81,8 @@ template void vector_randu() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; const std::string vecrandu_program = " var noise[6] := [0]; " @@ -109,9 +109,9 @@ void vector_randu() randu randu; symbol_table_t symbol_table; - symbol_table.add_vector ("signal" , signal); - symbol_table.add_function("println",println); - symbol_table.add_function("randu" , randu); + symbol_table.add_vector ("signal" , signal ); + symbol_table.add_function("println", println); + symbol_table.add_function("randu" , randu ); expression_t expression; expression.register_symbol_table(symbol_table); diff --git a/exprtk_test.cpp b/exprtk_test.cpp index 91e7593..9e62b10 100644 --- a/exprtk_test.cpp +++ b/exprtk_test.cpp @@ -3,7 +3,7 @@ * C++ Mathematical Expression Toolkit Library * * * * Examples and Unit-Tests * - * Author: Arash Partow (1999-2020) * + * Author: Arash Partow (1999-2021) * * URL: http://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * @@ -358,6 +358,42 @@ static const test_t global_test_list[] = test_t("( 7 - 2 )",+5.0), test_t("( 8 - 1 )",+7.0), test_t("( 9 - 0 )",+9.0), + test_t("1 - -1" , 2.0), + test_t("1 --1" , 2.0), + test_t("1-- 1" , 2.0), + test_t("1--1" , 2.0), + test_t("1 -- -1", 0.0), + test_t("1 + -1" , 0.0), + test_t("1 +-1" , 0.0), + test_t("1+- 1" , 0.0), + test_t("1+-1" , 0.0), + test_t("1 +- -1", 2.0), + test_t("1 + +1" , 2.0), + test_t("1 ++1" , 2.0), + test_t("1 - -1 + 1" , 3.0), + test_t("1 --1 + 1" , 3.0), + test_t("1-- 1 + 1" , 3.0), + test_t("1--1 + 1" , 3.0), + test_t("1 -- -1 + 1", 1.0), + test_t("1 + -1 + 1" , 1.0), + test_t("1 +-1 + 1" , 1.0), + test_t("1+- 1 + 1" , 1.0), + test_t("1+-1 + 1" , 1.0), + test_t("1 +- -1 + 1", 3.0), + test_t("1 + +1 + 1" , 3.0), + test_t("1 ++1 + 1" , 3.0), + test_t("1 - -1 - 1" , 1.0), + test_t("1 --1 - 1" , 1.0), + test_t("1-- 1 - 1" , 1.0), + test_t("1--1 - 1" , 1.0), + test_t("1 -- -1 - 1", -1.0), + test_t("1 + -1 - 1" , -1.0), + test_t("1 +-1 - 1" , -1.0), + test_t("1+- 1 - 1" , -1.0), + test_t("1+-1 - 1" , -1.0), + test_t("1 +- -1 - 1", 1.0), + test_t("1 + +1 - 1" , 1.0), + test_t("1 ++1 - 1" , 1.0), test_t("-(1+2)",-3.0), test_t("+(1+2)",+3.0), test_t("+(1-2)",-1.0), @@ -1162,14 +1198,14 @@ inline bool test_expression(const std::string& expression_string, const T& expec return false; } - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,expected_result)) { printf("test_expression() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", expression_string.c_str(), - (double)expected_result, - (double)result); + static_cast(expected_result), + static_cast(result)); return false; } @@ -1177,6 +1213,43 @@ inline bool test_expression(const std::string& expression_string, const T& expec return true; } +template +struct edge_cases {}; + +template <> +struct edge_cases +{ + static inline std::vector test_cases() + { + std::vector cases; + cases.push_back(test_t(" 1.175494350822287508e-38", 1.175494350822287508e-38)); + cases.push_back(test_t(" 3.402823466385288598e+38", 3.402823466385288598e+38)); + cases.push_back(test_t("+1.175494350822287508e-38", +1.175494350822287508e-38)); + cases.push_back(test_t("+3.402823466385288598e+38", +3.402823466385288598e+38)); + cases.push_back(test_t("-1.175494350822287508e-38", -1.175494350822287508e-38)); + cases.push_back(test_t("-3.402823466385288598e+38", -3.402823466385288598e+38)); + + return cases; + } +}; + +template <> +struct edge_cases +{ + static inline std::vector test_cases() + { + std::vector cases; + cases.push_back(test_t(" 2.2250738585072013831e-308", 2.2250738585072013831e-308)); + cases.push_back(test_t(" 1.7976931348623157081e+308", 1.7976931348623157081e+308)); + cases.push_back(test_t("+2.2250738585072013831e-308", +2.2250738585072013831e-308)); + cases.push_back(test_t("+1.7976931348623157081e+308", +1.7976931348623157081e+308)); + cases.push_back(test_t("-2.2250738585072013831e-308", -2.2250738585072013831e-308)); + cases.push_back(test_t("-1.7976931348623157081e+308", -1.7976931348623157081e+308)); + + return cases; + } +}; + template inline bool run_test00() { @@ -1198,6 +1271,25 @@ inline bool run_test00() } } + { + const std::vector tests = edge_cases::test_cases(); + + bool result = true; + + for (std::size_t i = 0; i < tests.size(); ++i) + { + if (!test_expression(tests[i].first,T(tests[i].second))) + { + result = false; + } + } + + if (!result) + { + return false; + } + } + return true; } @@ -1256,34 +1348,106 @@ inline bool run_test01() test_xy("2 * (x + y) - 1" ,T(2.2),T(3.3),T(10.0 )), test_xy("y + (x + 1)" ,T(2.2),T(3.3),T(6.5 )), test_xy("(x + 1) + y" ,T(2.2),T(3.3),T(6.5 )), - test_xy("2 * x" ,T(2.2),T(0.0),T(4.4)), - test_xy("x * 2" ,T(2.2),T(0.0),T(4.4)), - test_xy("1.1 + x",T(2.2),T(0.0),T(3.3)), - test_xy("x + 1.1",T(2.2),T(0.0),T(3.3)), - test_xy("x * 1 == x" ,T(2.0),T(3.0),T(1.0)), - test_xy("1 * x == x" ,T(2.0),T(3.0),T(1.0)), - test_xy("y * 1 == y" ,T(2.0),T(3.0),T(1.0)), - test_xy("1 * y == y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * 0 == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("0 * x == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("y * 0 == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("0 * y == 0" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + 1 == 1 + x",T(2.0),T(3.0),T(1.0)), - test_xy("y + 1 == 1 + y",T(2.0),T(3.0),T(1.0)), - test_xy("x + y == y + x",T(2.0),T(3.0),T(1.0)), - test_xy("x * y == y * x",T(2.0),T(3.0),T(1.0)), - test_xy("x < y" ,T(2.0),T(3.0),T(1.0)), - test_xy("y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x <= y" ,T(2.0),T(3.0),T(1.0)), - test_xy("y >= x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + y > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x + y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * y > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("x * y > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x + y) > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x + y) > x" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x * y) > y" ,T(2.0),T(3.0),T(1.0)), - test_xy("(x * y) > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("2 * x" ,T(2.2),T(0.0),T(4.4)), + test_xy("x * 2" ,T(2.2),T(0.0),T(4.4)), + test_xy("1.1 + x" ,T(2.2),T(0.0),T(3.3)), + test_xy("x + 1.1" ,T(2.2),T(0.0),T(3.3)), + test_xy("x - -1 " ,T(1.0),T(0.0),T(2)), + test_xy("x --1 " ,T(1.0),T(0.0),T(2)), + test_xy("x-- 1 " ,T(1.0),T(0.0),T(2)), + test_xy("x--1 " ,T(1.0),T(0.0),T(2)), + test_xy("x -- -1" ,T(1.0),T(0.0),T(0)), + test_xy("x + -1 " ,T(1.0),T(0.0),T(0)), + test_xy("x +-1 " ,T(1.0),T(0.0),T(0)), + test_xy("x+- 1 " ,T(1.0),T(0.0),T(0)), + test_xy("x+-1 " ,T(1.0),T(0.0),T(0)), + test_xy("x +- -1" ,T(1.0),T(0.0),T(2)), + test_xy("x + +1 " ,T(1.0),T(0.0),T(2)), + test_xy("x ++1 " ,T(1.0),T(0.0),T(2)), + test_xy("1 - -x " ,T(1.0),T(0.0),T(2)), + test_xy("1 --x " ,T(1.0),T(0.0),T(2)), + test_xy("1-- x " ,T(1.0),T(0.0),T(2)), + test_xy("1--x " ,T(1.0),T(0.0),T(2)), + test_xy("1 -- -x" ,T(1.0),T(0.0),T(0)), + test_xy("1 + -x " ,T(1.0),T(0.0),T(0)), + test_xy("1 +-x " ,T(1.0),T(0.0),T(0)), + test_xy("1+- x " ,T(1.0),T(0.0),T(0)), + test_xy("1+-x " ,T(1.0),T(0.0),T(0)), + test_xy("1 +- -x" ,T(1.0),T(0.0),T(2)), + test_xy("1 + +x " ,T(1.0),T(0.0),T(2)), + test_xy("1 ++x " ,T(1.0),T(0.0),T(2)), + test_xy("(x - -1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x --1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x-- 1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x--1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x -- -1 + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x + -1 + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x +-1 + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x+- 1 + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x+-1 + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x +- -1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x + +1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x ++1 + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1 - -x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1 --x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1-- x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1--x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1 -- -x + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 + -x + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 +-x + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1+- x + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1+-x + 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 +- -x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1 + +x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(1 ++x + 1)" ,T(1.0),T(0.0),T(3)), + test_xy("(x - -1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x --1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x-- 1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x--1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x -- -1 - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(x + -1 - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(x +-1 - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(x+- 1 - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(x+-1 - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(x +- -1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x + +1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(x ++1 - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 - -x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 --x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1-- x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1--x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 -- -x - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(1 + -x - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(1 +-x - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(1+- x - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(1+-x - 1)" ,T(1.0),T(0.0),T(-1)), + test_xy("(1 +- -x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 + +x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("(1 ++x - 1)" ,T(1.0),T(0.0),T(1)), + test_xy("x * 1 == x" ,T(2.0),T(3.0),T(1.0)), + test_xy("1 * x == x" ,T(2.0),T(3.0),T(1.0)), + test_xy("y * 1 == y" ,T(2.0),T(3.0),T(1.0)), + test_xy("1 * y == y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * 0 == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("0 * x == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("y * 0 == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("0 * y == 0" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + 1 == 1 + x" ,T(2.0),T(3.0),T(1.0)), + test_xy("y + 1 == 1 + y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + y == y + x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * y == y * x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x < y" ,T(2.0),T(3.0),T(1.0)), + test_xy("y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x <= y" ,T(2.0),T(3.0),T(1.0)), + test_xy("y >= x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + y > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x + y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * y > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("x * y > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x + y) > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x + y) > x" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x * y) > y" ,T(2.0),T(3.0),T(1.0)), + test_xy("(x * y) > x" ,T(2.0),T(3.0),T(1.0)), test_xy("(2x + 3y) == (2*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), test_xy("2(x + y) == (2*x + 2*y)" ,T(2.0),T(3.0),T(1.0)), test_xy(" (x + y)3 == (3*x + 3*y)" ,T(2.0),T(3.0),T(1.0)), @@ -1646,14 +1810,14 @@ inline bool run_test01() } } - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,test.result)) { printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", test.expr.c_str(), - (double)test.result, - (double)result); + static_cast(test.result), + static_cast(result)); loop_result = false; } @@ -1758,14 +1922,14 @@ inline bool run_test01() } } - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,test.result)) { printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", test.expr.c_str(), - (double)test.result, - (double)result); + static_cast(test.result), + static_cast(result)); loop_result = false; } @@ -1841,14 +2005,14 @@ inline bool run_test01() } } - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,T(1))) { printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", expr_list[i].c_str(), - (double)1.0, - (double)result); + static_cast(1.0), + static_cast(result)); loop_result = false; } @@ -1901,14 +2065,14 @@ inline bool run_test01() } } - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,T(1))) { printf("run_test01() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\n", expr_list[i].c_str(), - (double)1.0, - (double)result); + static_cast(1.0), + static_cast(result)); loop_result = false; } } @@ -2422,6 +2586,17 @@ inline bool run_test02() test_ab("var i := 0; a[0:i+3] <=> b[:]; (a == '0123X') and (b == 'XXXX4567890')", "XXXXX","01234567890",T(1.0)), test_ab("var i := 0; a[0:i+4] <=> b[:]; (a == '01234') and (b == 'XXXXX567890')", "XXXXX","01234567890",T(1.0)), + test_ab("var y:= 2; '01234567890'[y:] == a ", "234567890","" ,T(1.0)), + test_ab("var y:= 2; '01234567890'[y:][y:] == a ", "4567890" ,"" ,T(1.0)), + test_ab("var y:= 2; '01234567890'[y:][y:][y:] == a ", "67890" ,"" ,T(1.0)), + test_ab("var y:= 2; '01234567890'[y:][y:][y:][y:] == a ", "890" ,"" ,T(1.0)), + test_ab("var y:= 2; '01234567890'[y:][y:][y:][y:][y:] == a", "0" ,"" ,T(1.0)), + test_ab("var y:= 2; '0123456789'[y:] == a ", "23456789" ,"" ,T(1.0)), + test_ab("var y:= 2; '0123456789'[y:][y:] == a ", "456789" ,"" ,T(1.0)), + test_ab("var y:= 2; '0123456789'[y:][y:][y:] == a ", "6789" ,"" ,T(1.0)), + test_ab("var y:= 2; '0123456789'[y:][y:][y:][y:] == a ", "89" ,"" ,T(1.0)), + test_ab("var y:= 2; '0123456789'[y:][y:][y:][y:][y:] == a ", "" ,"" ,T(1.0)), + test_ab("var x := 'XXXXX'; var y := '01234567890'; x[0:0] := y[:]; x == '0XXXX'", "","",T(1.0)), test_ab("var x := 'XXXXX'; var y := '01234567890'; x[0:1] := y[:]; x == '01XXX'", "","",T(1.0)), test_ab("var x := 'XXXXX'; var y := '01234567890'; x[0:2] := y[:]; x == '012XX'", "","",T(1.0)), @@ -2598,8 +2773,8 @@ inline bool run_test02() printf("run_test02() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f\t" "a='%s'\tb='%s'\tc='%s'\n", test.expr.c_str(), - (double)test.result, - (double)expr_result, + static_cast(test.result), + static_cast(expr_result), str_a.c_str(), str_b.c_str(), str_c.c_str()); @@ -2676,8 +2851,8 @@ template inline bool run_test03() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = "A+A0+aA+Aa0+b+B1+Bb+bB1+A+A0+AA+AA0+B+B1+BB+BB1+a+a0+aa+aa0+b+b1+bb+bb1+" "c+C2+Cc+Cc2+D+D3+dD+dD3+C+C2+CC+CC2+D+D3+DD+DD3+c+c2+cc+cc2+d+d3+dd+dd3+" @@ -3013,10 +3188,10 @@ inline bool run_test04() { printf("run_test04() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f x:%19.15f\ty:%19.15f\n", expression_string.c_str(), - (double)result1, - (double)result2, - (double)x, - (double)y); + static_cast(result1), + static_cast(result2), + static_cast(x), + static_cast(y)); return false; } @@ -3083,10 +3258,10 @@ inline bool run_test05() { printf("run_test05() - Computation Error: Expression: [%s]\tExpected: %19.15f\tResult: %19.15f x:%19.15f\ty:%19.15f\tIndex:%d\n", expression_string.c_str(), - (double)real_result, - (double)result, - (double)x, - (double)y, + static_cast(real_result), + static_cast(result), + static_cast(x), + static_cast(y), static_cast(i)); return false; @@ -3140,8 +3315,8 @@ inline bool run_test06() if (not_equal(total_area1,T(pi) / T(2),T(0.000001))) { printf("run_test06() - Integration Error: Expected: %19.15f\tResult: %19.15f\n", - (double)(pi / T(2)), - (double)total_area1); + static_cast(pi / T(2)), + static_cast(total_area1)); return false; } @@ -3192,9 +3367,9 @@ inline bool run_test07() if (not_equal(deriv1_result1,deriv1_real_result,T(0.00001))) { printf("run_test07() - 1st Derivative Error: x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n", - (double)x, - (double)deriv1_real_result, - (double)deriv1_result1); + static_cast(x), + static_cast(deriv1_real_result), + static_cast(deriv1_result1)); return false; } @@ -3214,9 +3389,9 @@ inline bool run_test07() if (not_equal(deriv2_result1,deriv2_real_result,T(0.01))) { printf("run_test07() - 2nd Derivative Error: x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n", - (double)x, - (double)deriv2_real_result, - (double)deriv2_result1); + static_cast(x), + static_cast(deriv2_real_result), + static_cast(deriv2_result1)); return false; } @@ -3236,9 +3411,9 @@ inline bool run_test07() if (not_equal(deriv3_result1,deriv3_real_result,T(0.01))) { printf("run_test07() - 3rd Derivative Error: x: %19.15f\tExpected: %19.15f\tResult: %19.15f\n", - (double)x, - (double)deriv3_real_result, - (double)deriv3_result1); + static_cast(x), + static_cast(deriv3_real_result), + static_cast(deriv3_result1)); return false; } @@ -3526,9 +3701,9 @@ inline bool run_test09() const T pi = T(3.141592653589793238462643383279502); - T result = expression.value(); + const T result = expression.value(); - T expected = T(4) * + const T expected = T(4) * ( mf(sin(x*pi),y / T(2)) + mf(sin(x*pi),y / T(2)) + @@ -3545,8 +3720,8 @@ inline bool run_test09() if (not_equal(result,expected,T(0.0000001))) { printf("run_test09() - Error Expected: %19.15f\tResult: %19.15f\n", - (double)expected, - (double)result); + static_cast(expected), + static_cast(result)); return false; } @@ -4311,6 +4486,78 @@ inline bool run_test10() { "var x; 1", "var x := 1; x", + "var x:= 1; x - -1 == 2", + "var x:= 1; x --1 == 2", + "var x:= 1; x-- 1 == 2", + "var x:= 1; x--1 == 2", + "var x:= 1; x -- -1== 0", + "var x:= 1; x + -1 == 0", + "var x:= 1; x +-1 == 0", + "var x:= 1; x+- 1 == 0", + "var x:= 1; x+-1 == 0", + "var x:= 1; x +- -1== 2", + "var x:= 1; x + +1 == 2", + "var x:= 1; x ++1 == 2", + "var x:= 1; 1 - -x == 2", + "var x:= 1; 1 --x == 2", + "var x:= 1; 1-- x == 2", + "var x:= 1; 1--x == 2", + "var x:= 1; 1 -- -x== 0", + "var x:= 1; 1 + -x == 0", + "var x:= 1; 1 +-x == 0", + "var x:= 1; 1+- x == 0", + "var x:= 1; 1+-x == 0", + "var x:= 1; 1 +- -x== 2", + "var x:= 1; 1 + +x == 2", + "var x:= 1; 1 ++x == 2", + "var x:= 1; (x - -1 + 1) == 3", + "var x:= 1; (x --1 + 1) == 3", + "var x:= 1; (x-- 1 + 1) == 3", + "var x:= 1; (x--1 + 1) == 3", + "var x:= 1; (x -- -1 + 1) == 1", + "var x:= 1; (x + -1 + 1) == 1", + "var x:= 1; (x +-1 + 1) == 1", + "var x:= 1; (x+- 1 + 1) == 1", + "var x:= 1; (x+-1 + 1) == 1", + "var x:= 1; (x +- -1 + 1) == 3", + "var x:= 1; (x + +1 + 1) == 3", + "var x:= 1; (x ++1 + 1) == 3", + "var x:= 1; (1 - -x + 1) == 3", + "var x:= 1; (1 --x + 1) == 3", + "var x:= 1; (1-- x + 1) == 3", + "var x:= 1; (1--x + 1) == 3", + "var x:= 1; (1 -- -x + 1) == 1", + "var x:= 1; (1 + -x + 1) == 1", + "var x:= 1; (1 +-x + 1) == 1", + "var x:= 1; (1+- x + 1) == 1", + "var x:= 1; (1+-x + 1) == 1", + "var x:= 1; (1 +- -x + 1) == 3", + "var x:= 1; (1 + +x + 1) == 3", + "var x:= 1; (1 ++x + 1) == 3", + "var x:= 1; (x - -1 - 1) == 1", + "var x:= 1; (x --1 - 1) == 1", + "var x:= 1; (x-- 1 - 1) == 1", + "var x:= 1; (x--1 - 1) == 1", + "var x:= 1; (x -- -1 - 1) == -1", + "var x:= 1; (x + -1 - 1) == -1", + "var x:= 1; (x +-1 - 1) == -1", + "var x:= 1; (x+- 1 - 1) == -1", + "var x:= 1; (x+-1 - 1) == -1", + "var x:= 1; (x +- -1 - 1) == 1", + "var x:= 1; (x + +1 - 1) == 1", + "var x:= 1; (x ++1 - 1) == 1", + "var x:= 1; (1 - -x - 1) == 1", + "var x:= 1; (1 --x - 1) == 1", + "var x:= 1; (1-- x - 1) == 1", + "var x:= 1; (1--x - 1) == 1", + "var x:= 1; (1 -- -x - 1) == -1", + "var x:= 1; (1 + -x - 1) == -1", + "var x:= 1; (1 +-x - 1) == -1", + "var x:= 1; (1+- x - 1) == -1", + "var x:= 1; (1+-x - 1) == -1", + "var x:= 1; (1 +- -x - 1) == 1", + "var x:= 1; (1 + +x - 1) == 1", + "var x:= 1; (1 ++x - 1) == 1", "var x := 1; var y := 2; 1", "var x := 1; var y := 2; x", "var x:=6; var y:=4; x + -3 == 3", @@ -4623,7 +4870,43 @@ inline bool run_test10() "var s := 'abc'; ~{1 + 2; 'abc' + s; s} == s ", "var s := 'abc'; ~{1 + 2; var x := 'ab'; x + 'c'} == s ", - "var x[10^6] := null; var y[10^7] := null; 0 * (min(x) + min(y)) + x[] + y[] == 10^7 + 10^6" + "var x[10^6] := null; var y[10^7] := null; 0 * (min(x) + min(y)) + x[] + y[] == 10^7 + 10^6", + + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 < 2, v0, v1) == v0", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 > 2, v0, v1) == v1", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 < 2, v0 - v1, v1 - v0) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; if (1 > 2, v0 - v1, v1 - v0) == (v1 - v0)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; if (x < y, v0, v1) == v0", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; if (x > y, v0, v1) == v1", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; if (x < y, v0 - v1, v1 - v0) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; if (x > y, v0 - v1, v1 - v0) == (v1 - v0)", + + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 < 2, v0, v1) == v0", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 > 2, v0, v1) == v1", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 < 2, v0 - v1, v1 - v0) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; if (1 > 2, v0 - v1, v1 - v0) == (v1 - v0)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; if (x < y, v0, v1) == v0", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; if (x > y, v0, v1) == v1", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; if (x < y, v0 - v1, v1 - v0) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; if (x > y, v0 - v1, v1 - v0) == (v1 - v0)", + + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 < 2) v0; else v1;) == v0", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 > 2) v0; else v1;) == v1", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 < 2) v0 - v1; else v1 - v0;) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; (if (1 > 2) v0 - v1; else v1 - v0;) == (v1 - v0)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; (if (x < y) v0; else v1;) == v0", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; (if (x > y) v0; else v1;) == v1", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; (if (x < y) v0 - v1; else v1 - v0;) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[3] := {7,8,9}; var x := 1; var y := 2; (if (x > y) v0 - v1; else v1 - v0;) == (v1 - v0)", + + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 < 2) v0; else v1;) == v0", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 > 2) v0; else v1;) == v1", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 < 2) v0 - v1; else v1 - v0;) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; (if (1 > 2) v0 - v1; else v1 - v0;) == (v1 - v0)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; (if (x < y) v0; else v1;) == v0", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; (if (x > y) v0; else v1;) == v1", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; (if (x < y) v0 - v1; else v1 - v0;) == (v0 - v1)", + "var v0[3] := {1,2,3}; var v1[4] := {6,7,8,9}; var x := 1; var y := 2; (if (x > y) v0 - v1; else v1 - v0;) == (v1 - v0)", }; const std::size_t expression_list_size = sizeof(expression_list) / sizeof(std::string); @@ -4662,7 +4945,7 @@ inline bool run_test10() } } - T result = expression.value(); + const T result = expression.value(); if (T(1) != result) { @@ -4699,7 +4982,7 @@ inline bool run_test10() continue; } - T result = expression.value(); + const T result = expression.value(); if (T(1) != result) { @@ -4927,8 +5210,8 @@ template inline bool run_test13() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; static const std::string expression_string[] = { @@ -5287,8 +5570,8 @@ inline bool run_test15() if (not_equal(base_result,result)) { printf("run_test15() - Error in evaluation! (1) Base: %20.10f\tResult: %20.10f\tExpression: %s\n", - (double)base_result, - (double)result, + static_cast(base_result), + static_cast(result), expr_str_list[i].c_str()); failure = true; @@ -5917,6 +6200,96 @@ struct overload_func : exprtk::igeneric_function template inline bool run_test18() { + { + exprtk::symbol_table symbol_table; + symbol_table.remove_variable("x",true); + symbol_table.remove_variable("x",false); + symbol_table.remove_stringvar("x"); + symbol_table.remove_function("x"); + symbol_table.remove_vararg_function("x"); + symbol_table.remove_vector("x"); + } + + { + exprtk::symbol_table symbol_table; + + { + T x; + const bool result1 = symbol_table.add_variable("x", x); + const bool result2 = symbol_table.remove_variable("x"); + const bool result3 = symbol_table.remove_variable("x"); + + if (!result1 || !result2 || result3) + { + printf("run_test18() - Failed sym_tab add/remove [1]\n"); + } + } + + { + std::string x; + const bool result1 = symbol_table.add_stringvar("x", x); + const bool result2 = symbol_table.remove_stringvar("x"); + const bool result3 = symbol_table.remove_stringvar("x"); + + if (!result1 || !result2 || result3) + { + printf("run_test18() - Failed sym_tab add/remove [2]\n"); + } + } + + { + std::vector x(10,T(0)); + const bool result1 = symbol_table.add_vector("x", x); + const bool result2 = symbol_table.remove_vector("x"); + const bool result3 = symbol_table.remove_vector("x"); + + if (!result1 || !result2 || result3) + { + printf("run_test18() - Failed sym_tab add/remove [3]\n"); + } + } + + { + myfunc x; + const bool result1 = symbol_table.add_function("x", x); + const bool result2 = symbol_table.remove_function("x"); + const bool result3 = symbol_table.remove_function("x"); + + if (!result1 || !result2 || result3) + { + printf("run_test18() - Failed sym_tab add/remove [4]\n"); + } + } + + { + va_func x; + const bool result1 = symbol_table.add_function("x", x); + const bool result2 = symbol_table.remove_vararg_function("x"); + const bool result3 = symbol_table.remove_vararg_function("x"); + + if (!result1 || !result2 || result3) + { + printf("run_test18() - Failed sym_tab add/remove [5]\n"); + } + } + + { + symbol_table.add_function("foo1",foo1); + symbol_table.add_function("foo2",foo2); + symbol_table.add_function("foo3",foo3); + symbol_table.add_function("foo4",foo4); + symbol_table.add_function("foo5",foo5); + symbol_table.add_function("foo6",foo6); + + symbol_table.remove_function("foo1"); + symbol_table.remove_function("foo2"); + symbol_table.remove_function("foo3"); + symbol_table.remove_function("foo4"); + symbol_table.remove_function("foo5"); + symbol_table.remove_function("foo6"); + } + } + { typedef exprtk::expression expression_t; @@ -6001,8 +6374,8 @@ inline bool run_test18() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; T x = T(33); T y = T(77); @@ -6100,8 +6473,8 @@ inline bool run_test18() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; T x = T(33); T y = T(77); @@ -6278,8 +6651,8 @@ inline bool run_test18() for (std::size_t i = 0; i < expression_list_size; ++i) { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; T x = T(33); T y = T(77); @@ -6395,8 +6768,8 @@ inline bool run_test18() std::string s4 = "XXXXXXXXXXXXXXX"; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t symbol_table; @@ -6448,7 +6821,7 @@ inline bool run_test18() return false; } - T result = expression.value(); + const T result = expression.value(); if (result != T(1)) { @@ -6508,8 +6881,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t symbol_table; @@ -6579,8 +6952,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::vector v0; std::vector v1; @@ -6666,8 +7039,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::vector v0; std::vector s; @@ -6729,8 +7102,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::vector v0; std::vector s; @@ -6792,8 +7165,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::vector v0; std::vector s; @@ -6853,8 +7226,8 @@ inline bool run_test18() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; T v0[] = { T(0), T(1), T(2), T(3), T(4) }; T v1[] = { T(5), T(6), T(7), T(8), T(9) }; @@ -6917,8 +7290,8 @@ inline bool run_test18() bool failure = false; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; exprtk::rtl::vecops::package vecops_pkg; @@ -7041,7 +7414,7 @@ inline bool run_test18() continue; } - T result = expression.value(); + const T result = expression.value(); if (result != T(1)) { @@ -7351,11 +7724,11 @@ inline bool run_test18() template inline bool run_test19() { - typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; { T x = T(123.123); @@ -7564,7 +7937,7 @@ inline bool run_test19() continue; } - T result = expression.value(); + const T result = expression.value(); if (result_list[i] != result) { @@ -8061,15 +8434,15 @@ inline bool run_test19() { x = static_cast(i); - T result = expression.value(); + const T result = expression.value(); if (not_equal(result,std::sqrt(x),T(0.0000001))) { printf("run_test19() - Computation Error " "Expression: [%s]\tExpected: %12.8f\tResult: %12.8f\n", expression_str.c_str(), - (double)std::sqrt(x), - (double)result); + static_cast(std::sqrt(x)), + static_cast(result)); failure = true; } @@ -8191,7 +8564,7 @@ inline bool run_test19() sum += x; - T result = expression.value(); + const T result = expression.value(); if (result != sum) { @@ -8684,8 +9057,8 @@ template inline bool run_test21() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; T x = T(1.1); T y = T(2.2); diff --git a/readme.txt b/readme.txt index 8e4dc46..f0d363c 100644 --- a/readme.txt +++ b/readme.txt @@ -59,7 +59,7 @@ arithmetic operations, functions and processes: (05) Functions: abs, avg, ceil, clamp, equal, erf, erfc, exp, expm1, floor, frac, log, log10, log1p, log2, - logn, max, min, mul, ncdf, nequal, root, + logn, max, min, mul, ncdf, not_equal, root, round, roundn, sgn, sqrt, sum, swap, trunc (06) Trigonometry: acos, acosh, asin, asinh, atan, atanh, atan2, @@ -124,7 +124,7 @@ The most recent version of the C++ Mathematical Expression Toolkit Library including all updates and tests can be found at the following locations: - (a) Download: http://www.partow.net/programming/exprtk/index.html + (a) Download: https://www.partow.net/programming/exprtk/index.html (b) Repository: https://github.com/ArashPartow/exprtk https://github.com/ArashPartow/exprtk-extras @@ -321,7 +321,7 @@ of C++ compilers: +----------+---------------------------------------------------------+ | ncdf | Normal cumulative distribution function. (eg: ncdf(x)) | +----------+---------------------------------------------------------+ -| nequal | Not-equal test between x and y using normalised epsilon | +| not_equal| Not-equal test between x and y using normalised epsilon | +----------+---------------------------------------------------------+ | pow | x to the power of y. (eg: pow(x,y) == x ^ y) | +----------+---------------------------------------------------------+ @@ -767,8 +767,8 @@ normally would in a program, and when the expression is evaluated the current values assigned to the variables will be used. typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t symbol_table; expression_t expression; @@ -811,8 +811,8 @@ expansive discussion please review section [17 - Hierarchies Of Symbol Tables] typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t symbol_table0; symbol_table_t symbol_table1; @@ -869,7 +869,7 @@ a false result due to one or more of the following reasons: (2) Expression -A structure that holds an abstract syntax tree or AST for a specified +A structure that holds an Abstract Syntax Tree or AST for a specified expression and is used to evaluate said expression. Evaluation of the expression is accomplished by performing a post-order traversal of the AST. If a compiled Expression uses variables or user defined @@ -1342,7 +1342,7 @@ noted: Note: In example 6 from the above set, it is assumed the user defined -function foo has been registered as having a side_effect. By default +function foo has been registered as having a side-effect. By default all user defined functions are assumed to have side-effects, unless they are configured in their constructors to not have side-effects using the 'disable_has_side_effects' free function. For more @@ -2322,8 +2322,8 @@ methods, composited functions and implicitly registering the functions with the denoted symbol table. typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef exprtk::function_compositor compositor_t; + typedef typename compositor_t::function function_t; symbol_table_t symbol_table; @@ -2351,11 +2351,11 @@ expression, an instance of each function needs to be registered with a symbol_table that has been associated with the expression instance. The following demonstrates how all the pieces are put together: - typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::symbol_table symbol_table_t; typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::parser parser_t; typedef exprtk::function_compositor compositor_t; - typedef typename compositor_t::function function_t; + typedef typename compositor_t::function function_t; foo f; boo b; @@ -2747,7 +2747,7 @@ expression that makes use of various elements of each symbol table is then compiled and later on evaluated: typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; + typedef exprtk::expression expression_t; // Setup global constants symbol table symbol_table_t glbl_const_symbol_table; @@ -2908,8 +2908,8 @@ variables with the latter method using the 'unknown_symbol_resolver' component. typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t unknown_var_symbol_table; @@ -2981,8 +2981,8 @@ should raise a compilation error. The following example demonstrates a simple user defined USR: typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; template struct my_usr : public parser_t::unknown_symbol_resolver @@ -3458,8 +3458,8 @@ redefined as a function taking degree input. ... typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef typename parser_t::settings_store settings_t; @@ -3511,8 +3511,8 @@ expression will return normally. " return [x, y, x + y, x - y, 'return-call 3'] "; typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; symbol_table_t symbol_table; expression_t expression; @@ -3574,8 +3574,8 @@ itself to have the result variables be assigned the appropriate values. typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = " var x := 123.456; " @@ -3751,8 +3751,8 @@ expression's associated symbol table. In the following example, the file I/O package is made available for the given expression: typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; exprtk::rtl::io::file::package fileio_package; @@ -3980,9 +3980,9 @@ Simpson's rule. The integrate function has two overloads, where the variable of integration can either be passed as a reference or as a name in string form. Example usage of the function is as follows: - typedef exprtk::parser parser_t; - typedef exprtk::expression expression_t; typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = "sqrt(1 - (x^2))"; @@ -4015,9 +4015,9 @@ where the variable of differentiation can either be passed as a reference or as a name in string form. Example usage of the derivative function is as follows: - typedef exprtk::parser parser_t; - typedef exprtk::expression expression_t; typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = "sqrt(1 - (x^2))"; @@ -4054,9 +4054,9 @@ variable of differentiation can either be passed as a reference or as a name in string form. Example usage of the second_derivative function is as follows: - typedef exprtk::parser parser_t; - typedef exprtk::expression expression_t; typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = "sqrt(1 - (x^2))"; @@ -4093,9 +4093,9 @@ variable of differentiation can either be passed as a reference or as a name in string form. Example usage of the third_derivative function is as follows: - typedef exprtk::parser parser_t; - typedef exprtk::expression expression_t; typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; std::string expression_string = "sqrt(1 - (x^2))"; @@ -4310,7 +4310,7 @@ into account when using ExprTk: of that symbol-table, otherwise the result will be undefined behavior. - (10) Equal and Nequal are normalised-epsilon equality routines, + (10) Equal and not_equal are normalised-epsilon equality routines, which use epsilons of 0.0000000001 and 0.000001 for double and float types respectively. @@ -4517,9 +4517,9 @@ struct myfunc : public exprtk::ifunction int main() { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; - typedef exprtk::parser_error::type error_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::parser_error::type error_t; std::string expression_str = "z := 2 myfunc([4 + sin(x / pi)^3],y ^ 2)";