blob: c26a1b174674ec3eea7dc999666821429f3f1da9 [file] [log] [blame]
/*
* This define will disable the ability for expressions to have comments.
* Expressions that have comments when parsed with a build that has this
* option, will result in a compilation failure.
*/
// #define exprtk_disable_comments
/*
* This define will disable the loop-wise 'break' and 'continue'
* capabilities. Any expression that contains those keywords will result
* in a compilation failure.
*/
#define exprtk_disable_break_continue
/*
* This define will disable the short-circuit '&' (and) and '|' (or)
* operators
*/
#define exprtk_disable_sc_andor
/*
* This define will disable all enhanced features such as strength
* reduction and special function optimisations and expression specific
* type instantiations. This feature will reduce compilation times and
* binary sizes but will also result in massive performance degradation
* of expression evaluations.
*/
#define exprtk_disable_enhanced_features
/*
* This define will disable all string processing capabilities. Any
* expression that contains a string or string related syntax will result
* in a compilation failure.
*/
#define exprtk_disable_string_capabilities
#define exprtk_disable_rtl_io_file
#define exprtk_disable_return_statement
#define exprtk_disable_rtl_io
#define exprtk_disable_superscalar_unroll
/* include main exprtk header library */
#include <exprtk.hpp>
#include <cmath>
#include <limits>
#include <numeric>
/* For floating types. (float, double, long double et al) */
template <typename T>
struct FuncMaxIgnoreNaN : public exprtk::ivararg_function<T>
{
FuncMaxIgnoreNaN()
{
exprtk::set_min_num_args(*this, 2);
exprtk::set_max_num_args(*this, 255);
}
inline T operator()(const std::vector<T>& argList)
{
return std::reduce(std::begin(argList), std::end(argList),
std::numeric_limits<double>::quiet_NaN(),
[](auto a, auto b) {
if (std::isnan(b))
{
return a;
}
if (std::isnan(a))
{
return b;
}
return std::max(a, b);
});
}
};