@@ -812,34 +812,23 @@ namespace exprtk
812
812
#undef exprtk_register_int_type_tag
813
813
814
814
template <typename T>
815
- struct epsilon_type
816
- {
817
- static inline T value()
818
- {
819
- const T epsilon = T(0.0000000001);
820
- return epsilon;
821
- }
822
- };
815
+ struct epsilon_type {};
823
816
824
- template <>
825
- struct epsilon_type <float>
826
- {
827
- static inline float value()
828
- {
829
- const float epsilon = float(0.000001f);
830
- return epsilon;
831
- }
832
- };
817
+ #define exprtk_define_epsilon_type(Type, Epsilon) \
818
+ template <> struct epsilon_type<Type> \
819
+ { \
820
+ static inline Type value() \
821
+ { \
822
+ const Type epsilon = static_cast<Type>(Epsilon); \
823
+ return epsilon; \
824
+ } \
825
+ }; \
833
826
834
- template <>
835
- struct epsilon_type <long double>
836
- {
837
- static inline long double value()
838
- {
839
- const long double epsilon = static_cast<long double>(0.000000000001);
840
- return epsilon;
841
- }
842
- };
827
+ exprtk_define_epsilon_type(float , 0.000001f)
828
+ exprtk_define_epsilon_type(double , 0.0000000001)
829
+ exprtk_define_epsilon_type(long double, 0.000000000001)
830
+
831
+ #undef exprtk_define_epsilon_type
843
832
844
833
template <typename T>
845
834
inline bool is_nan_impl(const T v, real_type_tag)
@@ -1839,8 +1828,8 @@ namespace exprtk
1839
1828
template <typename T>
1840
1829
inline bool valid_exponent(const int exponent, numeric::details::real_type_tag)
1841
1830
{
1842
- return (std::numeric_limits<T>::min_exponent10 <= exponent) &&
1843
- (exponent <= std::numeric_limits <T>::max_exponent10) ;
1831
+ using namespace details::numeric;
1832
+ return (numeric_info<T>::min_exp <= exponent) && (exponent <= numeric_info <T>::max_exp) ;
1844
1833
}
1845
1834
1846
1835
template <typename Iterator, typename T>
@@ -1885,14 +1874,7 @@ namespace exprtk
1885
1874
1886
1875
while (end != itr)
1887
1876
{
1888
- // Note: For 'physical' superscalar architectures it
1889
- // is advised that the following loop be: 4xPD1 and 1xPD2
1890
1877
unsigned int digit;
1891
-
1892
- #ifdef exprtk_enable_superscalar
1893
- parse_digit_1(d)
1894
- parse_digit_1(d)
1895
- #endif
1896
1878
parse_digit_1(d)
1897
1879
parse_digit_1(d)
1898
1880
parse_digit_2(d)
@@ -1913,12 +1895,6 @@ namespace exprtk
1913
1895
while (end != itr)
1914
1896
{
1915
1897
unsigned int digit;
1916
-
1917
- #ifdef exprtk_enable_superscalar
1918
- parse_digit_1(tmp_d)
1919
- parse_digit_1(tmp_d)
1920
- parse_digit_1(tmp_d)
1921
- #endif
1922
1898
parse_digit_1(tmp_d)
1923
1899
parse_digit_1(tmp_d)
1924
1900
parse_digit_2(tmp_d)
@@ -1928,12 +1904,12 @@ namespace exprtk
1928
1904
{
1929
1905
instate = true;
1930
1906
1931
- const int exponent = static_cast<int>(-std::distance(curr, itr));
1907
+ const int frac_exponent = static_cast<int>(-std::distance(curr, itr));
1932
1908
1933
- if (!valid_exponent<T>(exponent , numeric::details::real_type_tag()))
1909
+ if (!valid_exponent<T>(frac_exponent , numeric::details::real_type_tag()))
1934
1910
return false;
1935
1911
1936
- d += compute_pow10(tmp_d, exponent );
1912
+ d += compute_pow10(tmp_d, frac_exponent );
1937
1913
}
1938
1914
1939
1915
#undef parse_digit_1
@@ -4404,7 +4380,7 @@ namespace exprtk
4404
4380
{
4405
4381
public:
4406
4382
4407
- parameter_list(std::vector<type_store>& pl)
4383
+ explicit parameter_list(std::vector<type_store>& pl)
4408
4384
: parameter_list_(pl)
4409
4385
{}
4410
4386
@@ -4461,12 +4437,12 @@ namespace exprtk
4461
4437
typedef type_store<T> type_store_t;
4462
4438
typedef ViewType value_t;
4463
4439
4464
- type_view(type_store_t& ts)
4440
+ explicit type_view(type_store_t& ts)
4465
4441
: ts_(ts),
4466
4442
data_(reinterpret_cast<value_t*>(ts_.data))
4467
4443
{}
4468
4444
4469
- type_view(const type_store_t& ts)
4445
+ explicit type_view(const type_store_t& ts)
4470
4446
: ts_(const_cast<type_store_t&>(ts)),
4471
4447
data_(reinterpret_cast<value_t*>(ts_.data))
4472
4448
{}
@@ -4511,11 +4487,11 @@ namespace exprtk
4511
4487
typedef type_store<T> type_store_t;
4512
4488
typedef T value_t;
4513
4489
4514
- scalar_view(type_store_t& ts)
4490
+ explicit scalar_view(type_store_t& ts)
4515
4491
: v_(*reinterpret_cast<value_t*>(ts.data))
4516
4492
{}
4517
4493
4518
- scalar_view(const type_store_t& ts)
4494
+ explicit scalar_view(const type_store_t& ts)
4519
4495
: v_(*reinterpret_cast<value_t*>(const_cast<type_store_t&>(ts).data))
4520
4496
{}
4521
4497
@@ -4802,7 +4778,7 @@ namespace exprtk
4802
4778
destruct (true)
4803
4779
{}
4804
4780
4805
- control_block(const std::size_t& dsize)
4781
+ explicit control_block(const std::size_t& dsize)
4806
4782
: ref_count(1 ),
4807
4783
size (dsize),
4808
4784
data (0 ),
@@ -4880,7 +4856,7 @@ namespace exprtk
4880
4856
: control_block_(control_block::create(0))
4881
4857
{}
4882
4858
4883
- vec_data_store(const std::size_t& size)
4859
+ explicit vec_data_store(const std::size_t& size)
4884
4860
: control_block_(control_block::create(size,reinterpret_cast<data_t>(0),true))
4885
4861
{}
4886
4862
@@ -6651,7 +6627,7 @@ namespace exprtk
6651
6627
{
6652
6628
public:
6653
6629
6654
- break_exception(const T& v)
6630
+ explicit break_exception(const T& v)
6655
6631
: value(v)
6656
6632
{}
6657
6633
@@ -7559,13 +7535,13 @@ namespace exprtk
7559
7535
const std::size_t r1,
7560
7536
const std::size_t size) const
7561
7537
{
7562
- if (( r0 < 0) || (r0 >= size) )
7538
+ if (r0 >= size)
7563
7539
{
7564
7540
throw std::runtime_error("range error: (r0 < 0) || (r0 >= size)");
7565
7541
return false;
7566
7542
}
7567
7543
7568
- if (( r1 < 0) || (r1 >= size) )
7544
+ if (r1 >= size)
7569
7545
{
7570
7546
throw std::runtime_error("range error: (r1 < 0) || (r1 >= size)");
7571
7547
return false;
@@ -37500,8 +37476,16 @@ namespace exprtk
37500
37476
template <typename BaseFuncType>
37501
37477
struct scoped_bft
37502
37478
{
37503
- scoped_bft(BaseFuncType& bft) : bft_(bft) { bft_.pre (); }
37504
- ~scoped_bft() { bft_.post(); }
37479
+ explicit scoped_bft(BaseFuncType& bft)
37480
+ : bft_(bft)
37481
+ {
37482
+ bft_.pre ();
37483
+ }
37484
+
37485
+ ~scoped_bft()
37486
+ {
37487
+ bft_.post();
37488
+ }
37505
37489
37506
37490
BaseFuncType& bft_;
37507
37491
0 commit comments