removed non const ref() function
This commit is contained in:
parent
86c7fea008
commit
ef2d4ba215
77
exprtk.hpp
77
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)
|
||||||
{
|
{
|
||||||
T& x = var->ref();
|
#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();
|
||||||
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();
|
||||||
|
@ -40356,7 +40409,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r1 - n + 1; i <= r1; ++i)
|
for (std::size_t i = r1 - n + 1; i <= r1; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
vec.set(i, T(0));
|
vec.set(i, T(0));
|
||||||
#else
|
#else
|
||||||
vec[i] = T(0);
|
vec[i] = T(0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40420,7 +40473,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i < r0 + n; ++i)
|
for (std::size_t i = r0; i < r0 + n; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
vec.set(i, T(0));
|
vec.set(i, T(0));
|
||||||
#else
|
#else
|
||||||
vec[i] = T(0);
|
vec[i] = T(0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40583,7 +40636,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i <= r1; ++i, ++j)
|
for (std::size_t i = r0; i <= r1; ++i, ++j)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
vec.set(i, base + (increment * j));
|
vec.set(i, base + (increment * j));
|
||||||
#else
|
#else
|
||||||
vec[i] = base + (increment * j);
|
vec[i] = base + (increment * j);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40678,7 +40731,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i <= r1; ++i)
|
for (std::size_t i = r0; i <= r1; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
y.set(i, (a * x[i]) + y[i]);
|
y.set(i, (a * x[i]) + y[i]);
|
||||||
#else
|
#else
|
||||||
y[i] = (a * x[i]) + y[i];
|
y[i] = (a * x[i]) + y[i];
|
||||||
#endif
|
#endif
|
||||||
|
@ -40730,7 +40783,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i <= r1; ++i)
|
for (std::size_t i = r0; i <= r1; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
y.set(i, (a * x[i]) + (b * y[i]));
|
y.set(i, (a * x[i]) + (b * y[i]));
|
||||||
#else
|
#else
|
||||||
y[i] = (a * x[i]) + (b * y[i]);
|
y[i] = (a * x[i]) + (b * y[i]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40839,7 +40892,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i <= r1; ++i)
|
for (std::size_t i = r0; i <= r1; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
z.set(i, (a * x[i]) + (b * y[i]));
|
z.set(i, (a * x[i]) + (b * y[i]));
|
||||||
#else
|
#else
|
||||||
z[i] = (a * x[i]) + (b * y[i]);
|
z[i] = (a * x[i]) + (b * y[i]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40891,7 +40944,7 @@ namespace exprtk
|
||||||
for (std::size_t i = r0; i <= r1; ++i)
|
for (std::size_t i = r0; i <= r1; ++i)
|
||||||
{
|
{
|
||||||
#ifdef exprtk_enable_vector_runtime_checks
|
#ifdef exprtk_enable_vector_runtime_checks
|
||||||
z.set(i, (a * x[i]) + b);
|
z.set(i, (a * x[i]) + b);
|
||||||
#else
|
#else
|
||||||
z[i] = (a * x[i]) + b;
|
z[i] = (a * x[i]) + b;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue