From 38034fa5768fa5cd88790a729b511fbcfb782d04 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:18:24 -0400 Subject: [PATCH] Fix Clang-15 warnings (#831) Redundant casts, noexcept for move constructors, and usage of default and delete make the code more performant and maintainable. --- include/boost/math/concepts/std_real_concept.hpp | 1 - .../boost/math/differentiation/lanczos_smoothing.hpp | 4 ++-- include/boost/math/distributions/complement.hpp | 12 ++++++------ .../boost/math/distributions/hyperexponential.hpp | 2 +- .../boost/math/distributions/kolmogorov_smirnov.hpp | 4 ++-- include/boost/math/policies/error_handling.hpp | 6 ++---- include/boost/math/policies/policy.hpp | 4 ++-- .../boost/math/quadrature/detail/exp_sinh_detail.hpp | 2 +- .../detail/ooura_fourier_integrals_detail.hpp | 4 ++-- .../math/quadrature/detail/sinh_sinh_detail.hpp | 2 +- .../math/quadrature/detail/tanh_sinh_detail.hpp | 4 ++-- include/boost/math/quadrature/naive_monte_carlo.hpp | 8 ++++---- .../detail/hypergeometric_1F1_bessel.hpp | 8 ++++---- .../detail/hypergeometric_1F1_recurrence.hpp | 6 +++--- .../special_functions/detail/t_distribution_inv.hpp | 2 +- include/boost/math/special_functions/expm1.hpp | 4 ++-- .../boost/math/special_functions/heuman_lambda.hpp | 1 - include/boost/math/special_functions/legendre.hpp | 2 +- .../math/special_functions/legendre_stieltjes.hpp | 7 +++---- include/boost/math/special_functions/log1p.hpp | 4 ++-- include/boost/math/special_functions/sin_pi.hpp | 2 +- include/boost/math/special_functions/ulp.hpp | 6 +++--- include/boost/math/tools/polynomial.hpp | 4 ++-- include/boost/math/tools/polynomial_gcd.hpp | 1 - include/boost/math/tools/recurrence.hpp | 2 +- include/boost/math/tools/stats.hpp | 5 ++--- include/boost/math/tools/toms748_solve.hpp | 10 +++++----- include/boost/math/tools/ulps_plot.hpp | 6 +++--- 28 files changed, 58 insertions(+), 65 deletions(-) diff --git a/include/boost/math/concepts/std_real_concept.hpp b/include/boost/math/concepts/std_real_concept.hpp index fe9ebbf544..277c35cafd 100644 --- a/include/boost/math/concepts/std_real_concept.hpp +++ b/include/boost/math/concepts/std_real_concept.hpp @@ -340,7 +340,6 @@ inline std::basic_istream& operator>>(std::basic_istream #include namespace boost{ namespace math{ diff --git a/include/boost/math/differentiation/lanczos_smoothing.hpp b/include/boost/math/differentiation/lanczos_smoothing.hpp index 4fc7954552..a314288e48 100644 --- a/include/boost/math/differentiation/lanczos_smoothing.hpp +++ b/include/boost/math/differentiation/lanczos_smoothing.hpp @@ -569,8 +569,8 @@ class discrete_lanczos_derivative { discrete_lanczos_derivative& operator=(const discrete_lanczos_derivative&) = delete; // Allow moves: - discrete_lanczos_derivative(discrete_lanczos_derivative&&) = default; - discrete_lanczos_derivative& operator=(discrete_lanczos_derivative&&) = default; + discrete_lanczos_derivative(discrete_lanczos_derivative&&) noexcept = default; + discrete_lanczos_derivative& operator=(discrete_lanczos_derivative&&) noexcept = default; private: std::vector m_f; diff --git a/include/boost/math/distributions/complement.hpp b/include/boost/math/distributions/complement.hpp index 26d0d49e6d..5c062a7cdf 100644 --- a/include/boost/math/distributions/complement.hpp +++ b/include/boost/math/distributions/complement.hpp @@ -29,7 +29,7 @@ struct complemented2_type const RealType& param; private: - complemented2_type& operator=(const complemented2_type&); + complemented2_type& operator=(const complemented2_type&) = delete; }; template @@ -47,7 +47,7 @@ struct complemented3_type const RealType1& param1; const RealType2& param2; private: - complemented3_type& operator=(const complemented3_type&); + complemented3_type& operator=(const complemented3_type&) = delete; }; template @@ -68,7 +68,7 @@ struct complemented4_type const RealType2& param2; const RealType3& param3; private: - complemented4_type& operator=(const complemented4_type&); + complemented4_type& operator=(const complemented4_type&) = delete; }; template @@ -92,7 +92,7 @@ struct complemented5_type const RealType3& param3; const RealType4& param4; private: - complemented5_type& operator=(const complemented5_type&); + complemented5_type& operator=(const complemented5_type&) = delete; }; template @@ -119,7 +119,7 @@ struct complemented6_type const RealType4& param4; const RealType5& param5; private: - complemented6_type& operator=(const complemented6_type&); + complemented6_type& operator=(const complemented6_type&) = delete; }; template @@ -149,7 +149,7 @@ struct complemented7_type const RealType5& param5; const RealType6& param6; private: - complemented7_type& operator=(const complemented7_type&); + complemented7_type& operator=(const complemented7_type&) = delete; }; template diff --git a/include/boost/math/distributions/hyperexponential.hpp b/include/boost/math/distributions/hyperexponential.hpp index 68e1f37c4a..49f967d0fa 100644 --- a/include/boost/math/distributions/hyperexponential.hpp +++ b/include/boost/math/distributions/hyperexponential.hpp @@ -137,7 +137,7 @@ bool check_dist(char const* function, std::vector const& probabilities, s if (probabilities.size() != rates.size()) { *presult = policies::raise_domain_error(function, - "The parameters \"probabilities\" and \"rates\" must have the same length, but their size differ by: %1%.", + R"(The parameters "probabilities" and "rates" must have the same length, but their size differ by: %1%.)", fabs(static_cast(probabilities.size())-static_cast(rates.size())), pol); return false; diff --git a/include/boost/math/distributions/kolmogorov_smirnov.hpp b/include/boost/math/distributions/kolmogorov_smirnov.hpp index 0d866ac4cc..0365b69838 100644 --- a/include/boost/math/distributions/kolmogorov_smirnov.hpp +++ b/include/boost/math/distributions/kolmogorov_smirnov.hpp @@ -140,7 +140,7 @@ RealType kolmogorov_smirnov_pdf_small_x(RealType x, RealType n, const Policy&) { if (x2n*x2n == 0.0) { return static_cast(0); } - while (1) { + while (true) { delta = exp(-RealType(i+0.5)*RealType(i+0.5)*pi2/(2*x2n)) * (RealType(i+0.5)*RealType(i+0.5)*pi2 - x2n); if (delta == 0.0) @@ -164,7 +164,7 @@ inline RealType kolmogorov_smirnov_pdf_large_x(RealType x, RealType n, const Pol RealType value = RealType(0), delta = RealType(0), last_delta = RealType(0); RealType eps = policies::get_epsilon(); int i = 1; - while (1) { + while (true) { delta = 8*x*i*i*exp(-2*i*i*x*x*n); if (delta == 0.0) diff --git a/include/boost/math/policies/error_handling.hpp b/include/boost/math/policies/error_handling.hpp index b4106b8683..a008157df0 100644 --- a/include/boost/math/policies/error_handling.hpp +++ b/include/boost/math/policies/error_handling.hpp @@ -152,8 +152,7 @@ void raise_error(const char* pfunction, const char* message) msg += ": "; msg += message; - E e(msg); - BOOST_MATH_THROW_EXCEPTION(e) + BOOST_MATH_THROW_EXCEPTION(E(msg)) } template @@ -183,8 +182,7 @@ void raise_error(const char* pfunction, const char* pmessage, const T& val) replace_all_in_string(message, "%1%", sval.c_str()); msg += message; - E e(msg); - BOOST_MATH_THROW_EXCEPTION(e) + BOOST_MATH_THROW_EXCEPTION(E(msg)) } #endif diff --git a/include/boost/math/policies/policy.hpp b/include/boost/math/policies/policy.hpp index 9e12145a1f..6daebaa64f 100644 --- a/include/boost/math/policies/policy.hpp +++ b/include/boost/math/policies/policy.hpp @@ -641,7 +641,7 @@ struct normalise, }; inline constexpr policy<> make_policy() noexcept -{ return policy<>(); } +{ return {}; } template inline constexpr typename normalise, A1>::type make_policy(const A1&) noexcept @@ -948,7 +948,7 @@ struct method_error_check { using domain_error_type = typename Policy::domain_error_type; using type = typename std::conditional< - (domain_error_type::value == throw_on_error) && (domain_error_type::value != user_error), + (domain_error_type::value == throw_on_error), std::false_type, std::true_type>::type; }; diff --git a/include/boost/math/quadrature/detail/exp_sinh_detail.hpp b/include/boost/math/quadrature/detail/exp_sinh_detail.hpp index 5ba6e98319..0c507f6704 100644 --- a/include/boost/math/quadrature/detail/exp_sinh_detail.hpp +++ b/include/boost/math/quadrature/detail/exp_sinh_detail.hpp @@ -131,7 +131,7 @@ class exp_sinh_detail mutable std::vector> m_weights; std::size_t m_max_refinements; #if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS) - mutable boost::math::detail::atomic_unsigned_type m_committed_refinements; + mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{}; mutable std::mutex m_mutex; #else mutable unsigned m_committed_refinements; diff --git a/include/boost/math/quadrature/detail/ooura_fourier_integrals_detail.hpp b/include/boost/math/quadrature/detail/ooura_fourier_integrals_detail.hpp index f4e38625c5..84d98ee84c 100644 --- a/include/boost/math/quadrature/detail/ooura_fourier_integrals_detail.hpp +++ b/include/boost/math/quadrature/detail/ooura_fourier_integrals_detail.hpp @@ -434,7 +434,7 @@ class ooura_fourier_sin_detail { Real rel_err_goal_; #ifdef BOOST_HAS_THREADS - std::atomic starting_level_; + std::atomic starting_level_{}; #else long starting_level_; #endif @@ -663,7 +663,7 @@ class ooura_fourier_cos_detail { Real rel_err_goal_; #ifdef BOOST_HAS_THREADS - std::atomic starting_level_; + std::atomic starting_level_{}; #else long starting_level_; #endif diff --git a/include/boost/math/quadrature/detail/sinh_sinh_detail.hpp b/include/boost/math/quadrature/detail/sinh_sinh_detail.hpp index 6fda745e69..b695ec74f4 100644 --- a/include/boost/math/quadrature/detail/sinh_sinh_detail.hpp +++ b/include/boost/math/quadrature/detail/sinh_sinh_detail.hpp @@ -132,7 +132,7 @@ class sinh_sinh_detail mutable std::vector> m_weights; std::size_t m_max_refinements; #if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS) - mutable boost::math::detail::atomic_unsigned_type m_committed_refinements; + mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{}; mutable std::mutex m_mutex; #else mutable unsigned m_committed_refinements; diff --git a/include/boost/math/quadrature/detail/tanh_sinh_detail.hpp b/include/boost/math/quadrature/detail/tanh_sinh_detail.hpp index ecb47b7acc..75f05e72b4 100644 --- a/include/boost/math/quadrature/detail/tanh_sinh_detail.hpp +++ b/include/boost/math/quadrature/detail/tanh_sinh_detail.hpp @@ -177,9 +177,9 @@ class tanh_sinh_detail mutable std::vector> m_abscissas; mutable std::vector> m_weights; mutable std::vector m_first_complements; - std::size_t m_max_refinements, m_inital_row_length; + std::size_t m_max_refinements, m_inital_row_length{}; #if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS) - mutable boost::math::detail::atomic_unsigned_type m_committed_refinements; + mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{}; mutable std::mutex m_mutex; #else mutable unsigned m_committed_refinements; diff --git a/include/boost/math/quadrature/naive_monte_carlo.hpp b/include/boost/math/quadrature/naive_monte_carlo.hpp index a1fcfb3d28..78c06a02aa 100644 --- a/include/boost/math/quadrature/naive_monte_carlo.hpp +++ b/include/boost/math/quadrature/naive_monte_carlo.hpp @@ -41,7 +41,7 @@ class naive_monte_carlo Real error_goal, bool singular = true, uint64_t threads = std::thread::hardware_concurrency(), - uint64_t seed = 0) noexcept : m_num_threads{threads}, m_seed{seed} + uint64_t seed = 0) noexcept : m_num_threads{threads}, m_seed{seed}, m_volume(1) { using std::numeric_limits; using std::sqrt; @@ -49,7 +49,7 @@ class naive_monte_carlo m_lbs.resize(n); m_dxs.resize(n); m_limit_types.resize(n); - m_volume = 1; + static const char* function = "boost::math::quadrature::naive_monte_carlo<%1%>"; for (uint64_t i = 0; i < n; ++i) { @@ -439,12 +439,12 @@ class naive_monte_carlo uint64_t m_num_threads; std::atomic m_seed; std::atomic m_error_goal; - std::atomic m_done; + std::atomic m_done{}; std::vector m_lbs; std::vector m_dxs; std::vector m_limit_types; Real m_volume; - std::atomic m_total_calls; + std::atomic m_total_calls{}; // I wanted these to be vectors rather than maps, // but you can't resize a vector of atomics. std::unique_ptr[]> m_thread_calls; diff --git a/include/boost/math/special_functions/detail/hypergeometric_1F1_bessel.hpp b/include/boost/math/special_functions/detail/hypergeometric_1F1_bessel.hpp index 181015d5f9..6c3a2bdb74 100644 --- a/include/boost/math/special_functions/detail/hypergeometric_1F1_bessel.hpp +++ b/include/boost/math/special_functions/detail/hypergeometric_1F1_bessel.hpp @@ -148,7 +148,7 @@ int n, cache_offset; long long log_scale; - hypergeometric_1F1_AS_13_3_7_tricomi_series operator=(const hypergeometric_1F1_AS_13_3_7_tricomi_series&); + hypergeometric_1F1_AS_13_3_7_tricomi_series operator=(const hypergeometric_1F1_AS_13_3_7_tricomi_series&) = delete; void refill_cache() { @@ -559,9 +559,9 @@ *j *= ratio; } - hypergeometric_1F1_AS_13_3_6_series(); - hypergeometric_1F1_AS_13_3_6_series(const hypergeometric_1F1_AS_13_3_6_series&); - hypergeometric_1F1_AS_13_3_6_series& operator=(const hypergeometric_1F1_AS_13_3_6_series&); + hypergeometric_1F1_AS_13_3_6_series() = delete; + hypergeometric_1F1_AS_13_3_6_series(const hypergeometric_1F1_AS_13_3_6_series&) = delete; + hypergeometric_1F1_AS_13_3_6_series& operator=(const hypergeometric_1F1_AS_13_3_6_series&) = delete; }; template diff --git a/include/boost/math/special_functions/detail/hypergeometric_1F1_recurrence.hpp b/include/boost/math/special_functions/detail/hypergeometric_1F1_recurrence.hpp index dbd1fbb230..300d95574f 100644 --- a/include/boost/math/special_functions/detail/hypergeometric_1F1_recurrence.hpp +++ b/include/boost/math/special_functions/detail/hypergeometric_1F1_recurrence.hpp @@ -36,7 +36,7 @@ { } - explicit hypergeometric_1F1_recurrence_a_coefficients(const hypergeometric_1F1_recurrence_a_coefficients&) = default; + hypergeometric_1F1_recurrence_a_coefficients(const hypergeometric_1F1_recurrence_a_coefficients&) = default; hypergeometric_1F1_recurrence_a_coefficients operator=(const hypergeometric_1F1_recurrence_a_coefficients&) = delete; @@ -67,7 +67,7 @@ { } - explicit hypergeometric_1F1_recurrence_b_coefficients(const hypergeometric_1F1_recurrence_b_coefficients&) = default; + hypergeometric_1F1_recurrence_b_coefficients(const hypergeometric_1F1_recurrence_b_coefficients&) = default; hypergeometric_1F1_recurrence_b_coefficients& operator=(const hypergeometric_1F1_recurrence_b_coefficients&) = delete; @@ -100,7 +100,7 @@ { } - explicit hypergeometric_1F1_recurrence_small_b_coefficients(const hypergeometric_1F1_recurrence_small_b_coefficients&) = default; + hypergeometric_1F1_recurrence_small_b_coefficients(const hypergeometric_1F1_recurrence_small_b_coefficients&) = default; hypergeometric_1F1_recurrence_small_b_coefficients operator=(const hypergeometric_1F1_recurrence_small_b_coefficients&) = delete; diff --git a/include/boost/math/special_functions/detail/t_distribution_inv.hpp b/include/boost/math/special_functions/detail/t_distribution_inv.hpp index bcbad38fca..9209b6d405 100644 --- a/include/boost/math/special_functions/detail/t_distribution_inv.hpp +++ b/include/boost/math/special_functions/detail/t_distribution_inv.hpp @@ -204,7 +204,7 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol) } template -T inverse_students_t(T df, T u, T v, const Policy& pol, bool* pexact = 0) +T inverse_students_t(T df, T u, T v, const Policy& pol, bool* pexact = nullptr) { // // df = number of degrees of freedom. diff --git a/include/boost/math/special_functions/expm1.hpp b/include/boost/math/special_functions/expm1.hpp index 74dd459e94..eec6356031 100644 --- a/include/boost/math/special_functions/expm1.hpp +++ b/include/boost/math/special_functions/expm1.hpp @@ -65,8 +65,8 @@ namespace detail int k; const T m_x; T m_term; - expm1_series(const expm1_series&); - expm1_series& operator=(const expm1_series&); + expm1_series(const expm1_series&) = delete; + expm1_series& operator=(const expm1_series&) = delete; }; template diff --git a/include/boost/math/special_functions/heuman_lambda.hpp b/include/boost/math/special_functions/heuman_lambda.hpp index a926745eb1..c2d16d46ed 100644 --- a/include/boost/math/special_functions/heuman_lambda.hpp +++ b/include/boost/math/special_functions/heuman_lambda.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/math/special_functions/legendre.hpp b/include/boost/math/special_functions/legendre.hpp index 791d6892c1..acbe2d211e 100644 --- a/include/boost/math/special_functions/legendre.hpp +++ b/include/boost/math/special_functions/legendre.hpp @@ -100,7 +100,7 @@ T legendre_p_prime_imp(unsigned l, T x, const Policy& pol, T* Pn T p0 = 1; T p1 = x; T p_prime; - bool odd = l & 1; + bool odd = (l & 1 == 1); // If the order is odd, we sum all the even polynomials: if (odd) { diff --git a/include/boost/math/special_functions/legendre_stieltjes.hpp b/include/boost/math/special_functions/legendre_stieltjes.hpp index 69f724264d..32a1668c1a 100644 --- a/include/boost/math/special_functions/legendre_stieltjes.hpp +++ b/include/boost/math/special_functions/legendre_stieltjes.hpp @@ -38,8 +38,7 @@ class legendre_stieltjes std::ptrdiff_t n = m - 1; std::ptrdiff_t q; std::ptrdiff_t r; - bool odd = n & 1; - if (odd) + if (n & 1 == 1) { q = 1; r = (n-1)/2 + 2; @@ -75,7 +74,7 @@ class legendre_stieltjes Real norm_sq() const { Real t = 0; - bool odd = m_m & 1; + bool odd = (m_m & 1 == 1); for (size_t i = 1; i < m_a.size(); ++i) { if(odd) @@ -101,7 +100,7 @@ class legendre_stieltjes Real p1 = x; Real Em; - bool odd = m_m & 1; + bool odd = (m_m & 1 == 1); if (odd) { Em = m_a[1]*p1; diff --git a/include/boost/math/special_functions/log1p.hpp b/include/boost/math/special_functions/log1p.hpp index 49588ddc50..8121a573cd 100644 --- a/include/boost/math/special_functions/log1p.hpp +++ b/include/boost/math/special_functions/log1p.hpp @@ -65,8 +65,8 @@ namespace detail int k; const T m_mult; T m_prod; - log1p_series(const log1p_series&); - log1p_series& operator=(const log1p_series&); + log1p_series(const log1p_series&) = delete; + log1p_series& operator=(const log1p_series&) = delete; }; // Algorithm log1p is part of C99, but is not yet provided by many compilers. diff --git a/include/boost/math/special_functions/sin_pi.hpp b/include/boost/math/special_functions/sin_pi.hpp index dd150c0284..78e9c4ea07 100644 --- a/include/boost/math/special_functions/sin_pi.hpp +++ b/include/boost/math/special_functions/sin_pi.hpp @@ -27,9 +27,9 @@ inline T sin_pi_imp(T x, const Policy& pol) if(x < 0) return -sin_pi_imp(T(-x), pol); // sin of pi*x: - bool invert; if(x < 0.5) return sin(constants::pi() * x); + bool invert; if(x < 1) { invert = true; diff --git a/include/boost/math/special_functions/ulp.hpp b/include/boost/math/special_functions/ulp.hpp index 532224e273..3c0616db0e 100644 --- a/include/boost/math/special_functions/ulp.hpp +++ b/include/boost/math/special_functions/ulp.hpp @@ -26,7 +26,7 @@ T ulp_imp(const T& val, const std::true_type&, const Policy& pol) int fpclass = (boost::math::fpclassify)(val); - if(fpclass == (int)FP_NAN) + if(fpclass == FP_NAN) { return policies::raise_domain_error( function, @@ -60,13 +60,13 @@ T ulp_imp(const T& val, const std::false_type&, const Policy& pol) int fpclass = (boost::math::fpclassify)(val); - if(fpclass == (int)FP_NAN) + if(fpclass == FP_NAN) { return policies::raise_domain_error( function, "Argument must be finite, but got %1%", val, pol); } - else if((fpclass == (int)FP_INFINITE) || (fabs(val) >= tools::max_value())) + else if((fpclass == FP_INFINITE) || (fabs(val) >= tools::max_value())) { return (val < 0 ? -1 : 1) * policies::raise_overflow_error(function, nullptr, pol); } diff --git a/include/boost/math/tools/polynomial.hpp b/include/boost/math/tools/polynomial.hpp index 17e4362de2..fdff23254c 100644 --- a/include/boost/math/tools/polynomial.hpp +++ b/include/boost/math/tools/polynomial.hpp @@ -283,7 +283,7 @@ class polynomial typedef typename std::vector::size_type size_type; // construct: - polynomial(){} + polynomial()= default; template polynomial(const U* data, unsigned order) @@ -379,7 +379,7 @@ class polynomial T operator()(T z) const { - return m_data.size() > 0 ? boost::math::tools::evaluate_polynomial(&m_data[0], z, m_data.size()) : T(0); + return m_data.size() > 0 ? boost::math::tools::evaluate_polynomial((m_data).data(), z, m_data.size()) : T(0); } std::vector chebyshev() const { diff --git a/include/boost/math/tools/polynomial_gcd.hpp b/include/boost/math/tools/polynomial_gcd.hpp index 4d5fdebe52..6a3b9b07bb 100644 --- a/include/boost/math/tools/polynomial_gcd.hpp +++ b/include/boost/math/tools/polynomial_gcd.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/math/tools/recurrence.hpp b/include/boost/math/tools/recurrence.hpp index a0077a8f9b..10b3c097b2 100644 --- a/include/boost/math/tools/recurrence.hpp +++ b/include/boost/math/tools/recurrence.hpp @@ -50,7 +50,7 @@ namespace boost { } private: - function_ratio_from_backwards_recurrence_fraction operator=(const function_ratio_from_backwards_recurrence_fraction&); + function_ratio_from_backwards_recurrence_fraction operator=(const function_ratio_from_backwards_recurrence_fraction&) = delete; Recurrence r; int k; diff --git a/include/boost/math/tools/stats.hpp b/include/boost/math/tools/stats.hpp index 312f152800..1f87c4e659 100644 --- a/include/boost/math/tools/stats.hpp +++ b/include/boost/math/tools/stats.hpp @@ -24,8 +24,7 @@ class stats : m_min(tools::max_value()), m_max(-tools::max_value()), m_total(0), - m_squared_total(0), - m_count(0) + m_squared_total(0) {} void add(const T& val) { @@ -77,7 +76,7 @@ class stats } private: T m_min, m_max, m_total, m_squared_total; - std::uintmax_t m_count; + std::uintmax_t m_count{0}; }; } // namespace tools diff --git a/include/boost/math/tools/toms748_solve.hpp b/include/boost/math/tools/toms748_solve.hpp index 81a78e03b0..2de491a951 100644 --- a/include/boost/math/tools/toms748_solve.hpp +++ b/include/boost/math/tools/toms748_solve.hpp @@ -32,9 +32,9 @@ template class eps_tolerance { public: - eps_tolerance() + eps_tolerance() : eps(4 * tools::epsilon()) { - eps = 4 * tools::epsilon(); + } eps_tolerance(unsigned bits) { @@ -52,7 +52,7 @@ class eps_tolerance struct equal_floor { - equal_floor(){} + equal_floor()= default; template bool operator()(const T& a, const T& b) { @@ -63,7 +63,7 @@ struct equal_floor struct equal_ceil { - equal_ceil(){} + equal_ceil()= default; template bool operator()(const T& a, const T& b) { @@ -74,7 +74,7 @@ struct equal_ceil struct equal_nearest_integer { - equal_nearest_integer(){} + equal_nearest_integer()= default; template bool operator()(const T& a, const T& b) { diff --git a/include/boost/math/tools/ulps_plot.hpp b/include/boost/math/tools/ulps_plot.hpp index 0039a0d5a6..8e3995673b 100644 --- a/include/boost/math/tools/ulps_plot.hpp +++ b/include/boost/math/tools/ulps_plot.hpp @@ -212,11 +212,11 @@ class ulps_plot { else { std::vector ys{-3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}; - for (size_t i = 0; i < ys.size(); ++i) + for (double & i : ys) { - if (min_y <= ys[i] && ys[i] <= max_y) + if (min_y <= i && i <= max_y) { - PreciseReal y_cord_dataspace = ys[i]; + PreciseReal y_cord_dataspace = i; PreciseReal y = y_scale(y_cord_dataspace); fs << "