removed non const ref() function
This commit is contained in:
parent
86c7fea008
commit
ef2d4ba215
59
exprtk.hpp
59
exprtk.hpp
|
@ -7586,11 +7586,17 @@ namespace exprtk
|
||||||
{
|
{
|
||||||
*value_ = val;
|
*value_ = val;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
inline T* value_ptr()
|
||||||
|
{
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
#else
|
||||||
inline T& ref() exprtk_override
|
inline T& ref() exprtk_override
|
||||||
{
|
{
|
||||||
return (*value_);
|
return (*value_);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inline const T& ref() const exprtk_override
|
inline const T& ref() const exprtk_override
|
||||||
{
|
{
|
||||||
|
@ -8183,8 +8189,15 @@ namespace exprtk
|
||||||
|
|
||||||
inline T value() const exprtk_override
|
inline T value() const exprtk_override
|
||||||
{
|
{
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
const T tmp = var1_->ref();
|
||||||
|
var1_->set(var0_->ref());
|
||||||
|
var0_->set(tmp);
|
||||||
|
return tmp;
|
||||||
|
#else
|
||||||
std::swap(var0_->ref(),var1_->ref());
|
std::swap(var0_->ref(),var1_->ref());
|
||||||
return var1_->ref();
|
return var1_->ref();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline typename expression_node<T>::node_type type() const exprtk_override
|
inline typename expression_node<T>::node_type type() const exprtk_override
|
||||||
|
@ -10458,9 +10471,13 @@ namespace exprtk
|
||||||
if (var_node_ptr_)
|
if (var_node_ptr_)
|
||||||
{
|
{
|
||||||
assert(branch(1));
|
assert(branch(1));
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
T result = branch(1)->value();
|
||||||
|
var_node_ptr_->set(result);
|
||||||
|
#else
|
||||||
T& result = var_node_ptr_->ref();
|
T& result = var_node_ptr_->ref();
|
||||||
result = branch(1)->value();
|
result = branch(1)->value();
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -12742,7 +12759,7 @@ namespace exprtk
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ts.size = 1;
|
ts.size = 1;
|
||||||
ts.data = &var->ref();
|
ts.data = var->value_ptr();
|
||||||
ts.type = type_store_t::e_scalar;
|
ts.type = type_store_t::e_scalar;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -37795,12 +37812,21 @@ namespace exprtk
|
||||||
|
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
T& x = *(var->value_ptr());
|
||||||
|
const T x_original = x;
|
||||||
|
const T result = integrate(e, x, r0, r1, number_of_intervals);
|
||||||
|
var->set(x_original);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
T& x = var->ref();
|
T& x = var->ref();
|
||||||
const T x_original = x;
|
const T x_original = x;
|
||||||
const T result = integrate(e, x, r0, r1, number_of_intervals);
|
const T result = integrate(e, x, r0, r1, number_of_intervals);
|
||||||
x = x_original;
|
x = x_original;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return std::numeric_limits<T>::quiet_NaN();
|
return std::numeric_limits<T>::quiet_NaN();
|
||||||
|
@ -37886,12 +37912,21 @@ namespace exprtk
|
||||||
|
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
T& x = *(var->value_ptr());
|
||||||
|
const T x_original = x;
|
||||||
|
const T result = derivative(e, x, h);
|
||||||
|
var->set(x_original);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
T& x = var->ref();
|
T& x = var->ref();
|
||||||
const T x_original = x;
|
const T x_original = x;
|
||||||
const T result = derivative(e, x, h);
|
const T result = derivative(e, x, h);
|
||||||
x = x_original;
|
x = x_original;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return std::numeric_limits<T>::quiet_NaN();
|
return std::numeric_limits<T>::quiet_NaN();
|
||||||
|
@ -37913,12 +37948,21 @@ namespace exprtk
|
||||||
|
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
T &x = *(var->value_ptr());
|
||||||
|
const T x_original = x;
|
||||||
|
const T result = second_derivative(e, x, h);
|
||||||
|
var->set(x_original);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
T& x = var->ref();
|
T& x = var->ref();
|
||||||
const T x_original = x;
|
const T x_original = x;
|
||||||
const T result = second_derivative(e, x, h);
|
const T result = second_derivative(e, x, h);
|
||||||
x = x_original;
|
x = x_original;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return std::numeric_limits<T>::quiet_NaN();
|
return std::numeric_limits<T>::quiet_NaN();
|
||||||
|
@ -37940,12 +37984,21 @@ namespace exprtk
|
||||||
|
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
|
T &x = *(var->value_ptr());
|
||||||
|
const T x_original = x;
|
||||||
|
const T result = third_derivative(e, x, h);
|
||||||
|
var->set(x_original);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#else
|
||||||
T& x = var->ref();
|
T& x = var->ref();
|
||||||
const T x_original = x;
|
const T x_original = x;
|
||||||
const T result = third_derivative(e, x, h);
|
const T result = third_derivative(e, x, h);
|
||||||
x = x_original;
|
x = x_original;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return std::numeric_limits<T>::quiet_NaN();
|
return std::numeric_limits<T>::quiet_NaN();
|
||||||
|
|
Loading…
Reference in New Issue