From 855e7f44aea6b5fe262108caa8461919576c0f6f Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 5 Aug 2024 10:14:05 +0200 Subject: [PATCH] Fix or silence a few more tidy warnings --- ql/experimental/math/laplaceinterpolation.cpp | 2 +- ql/instruments/makecds.cpp | 3 ++- ql/pricingengines/swap/discretizedswap.cpp | 2 +- test-suite/quantlibbenchmark.cpp | 6 +++--- test-suite/quantlibglobalfixture.cpp | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ql/experimental/math/laplaceinterpolation.cpp b/ql/experimental/math/laplaceinterpolation.cpp index f6e18effdd8..2aad7e25903 100644 --- a/ql/experimental/math/laplaceinterpolation.cpp +++ b/ql/experimental/math/laplaceinterpolation.cpp @@ -145,7 +145,7 @@ for (auto const& m : map_) // handling of the "corners", all second derivs are zero in the op // this directly generalizes Numerical Recipes, 3rd ed, eq 3.8.6 Real sum_corner_h = - std::accumulate(corner_h.begin(), corner_h.end(), Real(0.0), std::plus()); + std::accumulate(corner_h.begin(), corner_h.end(), Real(0.0), std::plus<>()); for (Size j = 0; j < dim.size(); ++j) { std::vector coord_j(coord); coord_j[j] = corner_neighbour_index[j]; diff --git a/ql/instruments/makecds.cpp b/ql/instruments/makecds.cpp index 44bb4940db2..75a69e17c86 100644 --- a/ql/instruments/makecds.cpp +++ b/ql/instruments/makecds.cpp @@ -64,7 +64,8 @@ namespace QuantLib { end = tradeDate + *tenor_; } } else { - end = *termDate_; + // we have two exclusive constructors; if we don't have a tenor, we have a term date + end = *termDate_; // NOLINT(bugprone-unchecked-optional-access) } Schedule schedule(protectionStart, end, couponTenor_, WeekendsOnly(), Following, diff --git a/ql/pricingengines/swap/discretizedswap.cpp b/ql/pricingengines/swap/discretizedswap.cpp index b1b51877876..f3dc89ba34a 100644 --- a/ql/pricingengines/swap/discretizedswap.cpp +++ b/ql/pricingengines/swap/discretizedswap.cpp @@ -59,7 +59,7 @@ namespace QuantLib { // NOLINTNEXTLINE(readability-implicit-bool-conversion) auto includeTodaysCashFlows = Settings::instance().includeTodaysCashFlows() && - *Settings::instance().includeTodaysCashFlows(); + *Settings::instance().includeTodaysCashFlows(); // NOLINT(bugprone-unchecked-optional-access) auto nrOfFixedCoupons = args.fixedResetDates.size(); fixedResetTimes_.resize(nrOfFixedCoupons); diff --git a/test-suite/quantlibbenchmark.cpp b/test-suite/quantlibbenchmark.cpp index ab2de19075d..6f876c612c8 100644 --- a/test-suite/quantlibbenchmark.cpp +++ b/test-suite/quantlibbenchmark.cpp @@ -121,6 +121,7 @@ namespace { Benchmark(Benchmark&& move) = default; Benchmark& operator=(const Benchmark &other) = default; Benchmark& operator=(Benchmark &&other) = default; + ~Benchmark() = default; double getCost() const { return cost_; } std::string getName() const { return name_; } @@ -262,8 +263,7 @@ namespace { std::string msg = "Unable to find the Boost test unit for Benchmark '"; msg += b.getName(); msg += "'"; - std::runtime_error err(msg); - throw err; + throw std::runtime_error(msg); } } } @@ -575,7 +575,7 @@ QL_BENCHMARK_DECLARE(RoundingTests, testClosest, 100000, 0.1); -int main(int argc, char* argv[] ) +int main(int argc, char* argv[] ) // NOLINT(bugprone-exception-escape) { const std::string clientModeStr = "--client_mode=true"; bool clientMode = false; diff --git a/test-suite/quantlibglobalfixture.cpp b/test-suite/quantlibglobalfixture.cpp index 9c5cdeb3643..40ba9388d28 100644 --- a/test-suite/quantlibglobalfixture.cpp +++ b/test-suite/quantlibglobalfixture.cpp @@ -103,7 +103,7 @@ QuantLibGlobalFixture::QuantLibGlobalFixture() { ? "reference date events are included,\n" : "reference date events are excluded,\n") << (settings.includeTodaysCashFlows() - ? (*settings.includeTodaysCashFlows() + ? (*settings.includeTodaysCashFlows() // NOLINT(bugprone-unchecked-optional-access) ? "today's cashflows are included,\n" : "today's cashflows are excluded,\n") : "") @@ -166,4 +166,4 @@ SpeedLevel speed_level(int argc, char** argv) { return Faster; } return Slow; -} \ No newline at end of file +}