From 5217c00fac528b937a92bdc6d72162b88c4d3290 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:07:40 +0000 Subject: [PATCH] Automated fixes by clang-tidy --- ql/any.hpp | 6 +--- ql/cashflows/cashflowvectors.cpp | 6 +--- ql/cashflows/timebasket.cpp | 2 +- .../analytic_cont_geom_av_price_heston.cpp | 2 +- .../analytic_discr_geom_av_price_heston.cpp | 2 +- .../commodities/commoditycurve.cpp | 2 +- .../commodities/commoditycurve.hpp | 2 +- ql/experimental/commodities/commoditytype.cpp | 2 +- .../commodities/energybasisswap.cpp | 2 +- .../commodities/energycommodity.cpp | 2 +- ql/experimental/commodities/energyfuture.cpp | 2 +- .../commodities/energyvanillaswap.cpp | 2 +- ql/experimental/commodities/paymentterm.cpp | 2 +- ql/experimental/commodities/unitofmeasure.cpp | 3 +- ql/experimental/credit/binomiallossmodel.hpp | 2 +- .../credit/randomdefaultlatentmodel.hpp | 2 +- ql/experimental/math/piecewiseintegral.cpp | 2 +- ql/experimental/models/squarerootclvmodel.cpp | 2 +- ql/experimental/swaptions/irregularswap.cpp | 4 +-- ql/experimental/variancegamma/fftengine.cpp | 2 +- ql/experimental/volatility/noarbsabr.hpp | 4 +-- .../volatility/noarbsabrabsprobs.cpp | 4 +-- ql/functional.hpp | 8 ++--- ql/indexes/inflationindex.hpp | 4 +-- ql/instrument.hpp | 2 +- ql/instruments/assetswap.cpp | 4 +-- ql/instruments/compositeinstrument.cpp | 2 +- ql/instruments/equitytotalreturnswap.cpp | 6 ++-- ql/instruments/floatfloatswap.cpp | 8 ++--- ql/instruments/impliedvolatility.hpp | 6 +--- ql/instruments/nonstandardswap.cpp | 6 ++-- ql/instruments/zerocouponswap.cpp | 2 +- ql/math/integrals/exponentialintegrals.hpp | 34 ++++++++----------- ql/math/interpolations/xabrinterpolation.hpp | 5 +-- ql/math/optimization/lmdif.cpp | 4 +-- ql/math/optimization/lmdif.hpp | 5 +-- .../fdmarithmeticaveragecondition.cpp | 2 +- .../fdmsimplestoragecondition.cpp | 2 +- .../fdmsimpleswingcondition.cpp | 2 +- .../utilities/localvolrndcalculator.cpp | 4 +-- ql/optional.cpp | 6 +--- ql/optional.hpp | 6 +--- ql/pricingengines/basket/stulzengine.cpp | 6 ++-- .../capfloor/mchullwhiteengine.cpp | 6 +--- ql/pricingengines/credit/isdacdsengine.cpp | 8 ++--- .../forward/replicatingvarianceswapengine.hpp | 2 +- ql/pricingengines/swap/cvaswapengine.cpp | 2 +- ql/processes/gsrprocesscore.cpp | 18 ++++------ ql/processes/gsrprocesscore.hpp | 6 +--- ql/shared_ptr.hpp | 6 +--- .../andreasenhugevolatilityinterpl.cpp | 4 +-- .../optionlet/optionletstripper2.cpp | 2 +- ql/time/schedule.hpp | 8 ++--- ql/timegrid.hpp | 2 +- ql/timeseries.hpp | 4 +-- ql/tuple.hpp | 6 +--- ql/utilities/dataformatters.cpp | 6 +--- ql/utilities/tracing.cpp | 8 +---- ql/utilities/tracing.hpp | 6 +--- ql/utilities/vectors.hpp | 6 +--- test-suite/americanoption.cpp | 4 +-- test-suite/bonds.cpp | 2 +- test-suite/cliquetoption.cpp | 2 +- test-suite/defaultprobabilitycurves.cpp | 2 +- test-suite/hestonmodel.cpp | 2 +- test-suite/piecewiseyieldcurve.cpp | 2 +- test-suite/quantooption.cpp | 2 +- 67 files changed, 109 insertions(+), 190 deletions(-) diff --git a/ql/any.hpp b/ql/any.hpp index d9248dffb1f..1822324d1c5 100644 --- a/ql/any.hpp +++ b/ql/any.hpp @@ -32,9 +32,7 @@ #include #endif -namespace QuantLib { - - namespace ext { +namespace QuantLib::ext { #if defined(QL_USE_STD_ANY) using std::any; // NOLINT(misc-unused-using-decls) @@ -46,6 +44,4 @@ namespace QuantLib { } -} - #endif diff --git a/ql/cashflows/cashflowvectors.cpp b/ql/cashflows/cashflowvectors.cpp index 6676ca3801d..b3f04095969 100644 --- a/ql/cashflows/cashflowvectors.cpp +++ b/ql/cashflows/cashflowvectors.cpp @@ -29,9 +29,7 @@ #include #include -namespace QuantLib { - - namespace detail { +namespace QuantLib::detail { Rate effectiveFixedRate(const std::vector& spreads, const std::vector& caps, @@ -55,5 +53,3 @@ namespace QuantLib { } } - -} diff --git a/ql/cashflows/timebasket.cpp b/ql/cashflows/timebasket.cpp index d9e467e8525..c2bd4446241 100644 --- a/ql/cashflows/timebasket.cpp +++ b/ql/cashflows/timebasket.cpp @@ -49,7 +49,7 @@ namespace QuantLib { Real value = j.second; Date pDate = Null(), nDate = Null(); - std::vector::const_iterator bi = + auto bi = std::lower_bound(sbuckets.begin(), sbuckets.end(), date); if (bi == sbuckets.end()) diff --git a/ql/experimental/asian/analytic_cont_geom_av_price_heston.cpp b/ql/experimental/asian/analytic_cont_geom_av_price_heston.cpp index 7d6b538f23d..9dbec73dd7c 100644 --- a/ql/experimental/asian/analytic_cont_geom_av_price_heston.cpp +++ b/ql/experimental/asian/analytic_cont_geom_av_price_heston.cpp @@ -140,7 +140,7 @@ namespace QuantLib { // For each offset, look up the value in the map and only evaluate function if it's not there for (int offset=1; offset<5; offset++) { int location = n-offset; - std::map >::const_iterator position = fLookupTable_.find(location); + auto position = fLookupTable_.find(location); if (position != fLookupTable_.end()) { std::complex value = position->second; fMinusN[offset-1] = value; diff --git a/ql/experimental/asian/analytic_discr_geom_av_price_heston.cpp b/ql/experimental/asian/analytic_discr_geom_av_price_heston.cpp index 0a6acdeebd0..16574726b60 100644 --- a/ql/experimental/asian/analytic_discr_geom_av_price_heston.cpp +++ b/ql/experimental/asian/analytic_discr_geom_av_price_heston.cpp @@ -152,7 +152,7 @@ namespace QuantLib { // omega_tilde calls itself recursivly, use lookup map to avoid extreme slowdown when k large std::complex omega_kp1 = 0.0; - std::map >::const_iterator position = omegaTildeLookupTable_.find(k+1); + auto position = omegaTildeLookupTable_.find(k+1); if (position != omegaTildeLookupTable_.end()) { std::complex value = position->second; diff --git a/ql/experimental/commodities/commoditycurve.cpp b/ql/experimental/commodities/commoditycurve.cpp index 395391bddb3..c3b47ed224c 100644 --- a/ql/experimental/commodities/commoditycurve.cpp +++ b/ql/experimental/commodities/commoditycurve.cpp @@ -70,7 +70,7 @@ namespace QuantLib { dates_.clear(); data_.clear(); - for (std::map::const_iterator i = prices.begin(); i != prices.end(); ++i) { + for (auto i = prices.begin(); i != prices.end(); ++i) { dates_.push_back(i->first); data_.push_back(i->second); } diff --git a/ql/experimental/commodities/commoditycurve.hpp b/ql/experimental/commodities/commoditycurve.hpp index 3d9b4607170..35dbac280f8 100644 --- a/ql/experimental/commodities/commoditycurve.hpp +++ b/ql/experimental/commodities/commoditycurve.hpp @@ -189,7 +189,7 @@ namespace QuantLib { const ext::shared_ptr& exchangeContracts, Integer nearbyOffset) const { QL_REQUIRE(nearbyOffset > 0, "nearby offset must be > 0"); - ExchangeContracts::const_iterator ic = + auto ic = exchangeContracts->lower_bound(date); if (ic != exchangeContracts->end()) { for (int i = 0; i < nearbyOffset-1 && ic!=exchangeContracts->end(); ++i) diff --git a/ql/experimental/commodities/commoditytype.cpp b/ql/experimental/commodities/commoditytype.cpp index e984043d4f2..595863c39e2 100644 --- a/ql/experimental/commodities/commoditytype.cpp +++ b/ql/experimental/commodities/commoditytype.cpp @@ -27,7 +27,7 @@ namespace QuantLib { CommodityType::CommodityType(const std::string& name, const std::string& code) { - std::map >::const_iterator i = commodityTypes_.find(code); + auto i = commodityTypes_.find(code); if (i != commodityTypes_.end()) data_ = i->second; else { diff --git a/ql/experimental/commodities/energybasisswap.cpp b/ql/experimental/commodities/energybasisswap.cpp index 8ce71b5ea42..5fbaf0c160d 100644 --- a/ql/experimental/commodities/energybasisswap.cpp +++ b/ql/experimental/commodities/energybasisswap.cpp @@ -290,7 +290,7 @@ namespace QuantLib { QL_REQUIRE(!paymentCashFlows_.empty(), "no cashflows"); - for (SecondaryCostAmounts::const_iterator i = + for (auto i = secondaryCostAmounts_.begin(); i != secondaryCostAmounts_.end(); ++i) { Real amount = i->second.value(); diff --git a/ql/experimental/commodities/energycommodity.cpp b/ql/experimental/commodities/energycommodity.cpp index 4ade5b1361d..a1fb887a3ea 100644 --- a/ql/experimental/commodities/energycommodity.cpp +++ b/ql/experimental/commodities/energycommodity.cpp @@ -142,7 +142,7 @@ namespace QuantLib { const Currency& baseCurrency = CommoditySettings::instance().currency(); try { - for (SecondaryCosts::const_iterator i = secondaryCosts_->begin(); + for (auto i = secondaryCosts_->begin(); i != secondaryCosts_->end(); ++i) { if (ext::any_cast(&i->second) != nullptr) { Real value = diff --git a/ql/experimental/commodities/energyfuture.cpp b/ql/experimental/commodities/energyfuture.cpp index 48994648222..c44a3a287e8 100644 --- a/ql/experimental/commodities/energyfuture.cpp +++ b/ql/experimental/commodities/energyfuture.cpp @@ -106,7 +106,7 @@ namespace QuantLib { calculateSecondaryCostAmounts(quantity_.commodityType(), quantity_.amount(), evaluationDate); - for (SecondaryCostAmounts::const_iterator i = secondaryCostAmounts_.begin(); i != secondaryCostAmounts_.end(); ++i) { + for (auto i = secondaryCostAmounts_.begin(); i != secondaryCostAmounts_.end(); ++i) { Real amount = i->second.value(); NPV_ -= amount; } diff --git a/ql/experimental/commodities/energyvanillaswap.cpp b/ql/experimental/commodities/energyvanillaswap.cpp index 5eda3e96c65..1f902a14242 100644 --- a/ql/experimental/commodities/energyvanillaswap.cpp +++ b/ql/experimental/commodities/energyvanillaswap.cpp @@ -250,7 +250,7 @@ namespace QuantLib { QL_REQUIRE(!paymentCashFlows_.empty(), "no cashflows"); - for (SecondaryCostAmounts::const_iterator i = + for (auto i = secondaryCostAmounts_.begin(); i != secondaryCostAmounts_.end(); ++i) { Real amount = i->second.value(); diff --git a/ql/experimental/commodities/paymentterm.cpp b/ql/experimental/commodities/paymentterm.cpp index e3ae2cdb80e..858dfe17894 100644 --- a/ql/experimental/commodities/paymentterm.cpp +++ b/ql/experimental/commodities/paymentterm.cpp @@ -28,7 +28,7 @@ namespace QuantLib { PaymentTerm::EventType eventType, Integer offsetDays, const Calendar& calendar) { - std::map >::const_iterator i = paymentTerms_.find(name); + auto i = paymentTerms_.find(name); if (i != paymentTerms_.end()) data_ = i->second; else { diff --git a/ql/experimental/commodities/unitofmeasure.cpp b/ql/experimental/commodities/unitofmeasure.cpp index f5b83de67ff..d0706bec9d8 100644 --- a/ql/experimental/commodities/unitofmeasure.cpp +++ b/ql/experimental/commodities/unitofmeasure.cpp @@ -37,8 +37,7 @@ namespace QuantLib { UnitOfMeasure::UnitOfMeasure(const std::string& name, const std::string& code, UnitOfMeasure::Type unitType) { - std::map >::const_iterator i = + auto i = unitsOfMeasure_.find(name); if (i != unitsOfMeasure_.end()) { data_ = i->second; diff --git a/ql/experimental/credit/binomiallossmodel.hpp b/ql/experimental/credit/binomiallossmodel.hpp index cf83e882d6b..cd3ea4a7b1e 100644 --- a/ql/experimental/credit/binomiallossmodel.hpp +++ b/ql/experimental/credit/binomiallossmodel.hpp @@ -354,7 +354,7 @@ namespace QuantLib { if(perc == 1.) return dist.rbegin()->first; if(perc == 0.) return dist.begin()->first; - std::map::const_iterator itdist = dist.begin(); + auto itdist = dist.begin(); while (itdist->second <= perc) ++itdist; Real valPlus = itdist->second; Real xPlus = itdist->first; diff --git a/ql/experimental/credit/randomdefaultlatentmodel.hpp b/ql/experimental/credit/randomdefaultlatentmodel.hpp index 98f8f7b4a3e..d4f3f4870eb 100644 --- a/ql/experimental/credit/randomdefaultlatentmodel.hpp +++ b/ql/experimental/credit/randomdefaultlatentmodel.hpp @@ -277,7 +277,7 @@ namespace QuantLib { events[iEvt].nameIdx)); } if(namesDefaulting.size() >= n) { - std::map::const_iterator + auto itdefs = namesDefaulting.begin(); // locate nth default in time: std::advance(itdefs, n-1); diff --git a/ql/experimental/math/piecewiseintegral.cpp b/ql/experimental/math/piecewiseintegral.cpp index 3947c23175c..daee6c780b6 100644 --- a/ql/experimental/math/piecewiseintegral.cpp +++ b/ql/experimental/math/piecewiseintegral.cpp @@ -31,7 +31,7 @@ namespace QuantLib { eps_(avoidCriticalPoints ? (1.0 + QL_EPSILON) : 1.0) { std::sort(criticalPoints_.begin(), criticalPoints_.end()); - std::vector::const_iterator end = + auto end = std::unique(criticalPoints_.begin(), criticalPoints_.end(), static_cast(close_enough)); criticalPoints_.resize(end - criticalPoints_.begin()); diff --git a/ql/experimental/models/squarerootclvmodel.cpp b/ql/experimental/models/squarerootclvmodel.cpp index 4391b0c0120..665b86f5f6f 100644 --- a/ql/experimental/models/squarerootclvmodel.cpp +++ b/ql/experimental/models/squarerootclvmodel.cpp @@ -160,7 +160,7 @@ namespace QuantLib { } Real SquareRootCLVModel::MappingFunction::operator()(Time t,Real x) const { - const interpl_type::const_iterator ge = interpl.lower_bound(t); + const auto ge = interpl.lower_bound(t); if (close_enough(ge->first, t)) { return (*ge->second)(x, true); diff --git a/ql/experimental/swaptions/irregularswap.cpp b/ql/experimental/swaptions/irregularswap.cpp index 0521b37789c..3e3d3943534 100644 --- a/ql/experimental/swaptions/irregularswap.cpp +++ b/ql/experimental/swaptions/irregularswap.cpp @@ -54,13 +54,13 @@ namespace QuantLib { //Fixed leg legs_[0] = fixLeg; - for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i) + for (auto i = legs_[0].begin(); i < legs_[0].end(); ++i) registerWith(*i); //Floating Leg legs_[1] = floatLeg; - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); } diff --git a/ql/experimental/variancegamma/fftengine.cpp b/ql/experimental/variancegamma/fftengine.cpp index 6cd6c6ca69b..b4053683452 100644 --- a/ql/experimental/variancegamma/fftengine.cpp +++ b/ql/experimental/variancegamma/fftengine.cpp @@ -101,7 +101,7 @@ namespace QuantLib { std::complex i1(0, 1); Real alpha = 1.25; - for (PayoffMap::const_iterator payIt = payoffMap.begin(); payIt != payoffMap.end(); ++payIt) + for (auto payIt = payoffMap.begin(); payIt != payoffMap.end(); ++payIt) { Date expiryDate = payIt->first; diff --git a/ql/experimental/volatility/noarbsabr.hpp b/ql/experimental/volatility/noarbsabr.hpp index e55071d084c..e6d81d488f5 100644 --- a/ql/experimental/volatility/noarbsabr.hpp +++ b/ql/experimental/volatility/noarbsabr.hpp @@ -58,8 +58,7 @@ namespace QuantLib { -namespace detail { -namespace NoArbSabrModel { +namespace detail::NoArbSabrModel { // parameter bounds const Real beta_min = 0.01; const Real beta_max = 0.99; @@ -97,7 +96,6 @@ const Real density_lower_bound = 1E-50; // threshold to identify a zero density const Real density_threshold = 1E-100; } -} class NoArbSabrModel { diff --git a/ql/experimental/volatility/noarbsabrabsprobs.cpp b/ql/experimental/volatility/noarbsabrabsprobs.cpp index a4f813deb0b..9193492932d 100644 --- a/ql/experimental/volatility/noarbsabrabsprobs.cpp +++ b/ql/experimental/volatility/noarbsabrabsprobs.cpp @@ -27,8 +27,7 @@ #include -namespace QuantLib { -namespace detail { +namespace QuantLib::detail { extern "C" const unsigned long sabrabsprob[] = {60342,291274,515252,694004,836701,953289,1050056,1132010,1202241,1263153,1316842,1364717,1407266,1446040,1481425,1513334,1543017,1569884,1594948,1618387,1640339,1660694,1679833,1698081,1715036,1731139,1746327,1760919,1774403,1787353,1799707,1811550,1822987,1833783,1844438,1854379,1864056,1873190,1881907,1890509,1898759,1906719,1914318,1921724,1928712,1935493,1942202,1948706,1954863,1961008,1966966,1972750,1978322,1983821,1989159,1994254,1999267,2004184,2008986,2013673,2018192,2022656,2026921,2031190,2035416,2039428,2043404,2047234,2051046,2054654,2058305,2061857,2065374,2068724,2072001,2075235,2078372,2081504,2084519,2087596,2090499,2093278,2096135,2098886,2101682,2104341,2107048,2109666,2112241,2114724,2117227,2119730,2122058,2124426,2126738,2129006,2131172,2133380,2135533,2137616,2139719,2141745,2143837,2145838,2147753,2149686,2151620,2153473,2155308,2157128,2158920,2160702,2162468,2164193,2165904,2167571,2169198,2170869,2172573,2174176, 12148,123121,282483,433350,565404,679824,778977,864809,941135,1007823,1067365,1121192,1169246,1213066,1253347,1290441,1325052,1357146,1386553,1414135,1439884,1463979,1486817,1508228,1528383,1547532,1565708,1583033,1599357,1615128,1630045,1644293,1658125,1671350,1684005,1696243,1707989,1719243,1729998,1740233,1750096,1759695,1769054,1778238,1786925,1795389,1803711,1811602,1819347,1826779,1834108,1841337,1848345,1855008,1861501,1867935,1874178,1880090,1885913,1891709,1897226,1902669,1908083,1913432,1918523,1923581,1928425,1933262,1937909,1942438,1946850,1951110,1955396,1959670,1963700,1967724,1971639,1975516,1979164,1982979,1986656,1990290,1993793,1997260,2000700,2003970,2007274,2010470,2013684,2016774,2019967,2022914,2025983,2028863,2031699,2034488,2037261,2039993,2042695,2045290,2047838,2050411,2052934,2055360,2057827,2060237,2062556,2064873,2067154,2069455,2071644,2073866,2076053,2078211,2080372,2082510,2084572,2086648,2088634,2090672, @@ -10111,5 +10110,4 @@ extern "C" const unsigned long sabrabsprob[] = {60342,291274,515252,694004,83670 0,0,0,0,0,5,29,77,203,384,678,1085,1652,2333,3105,3999,4963,6032,7171,8377,9563,10835,12216,13559,14881,16269,17624,19014,20288,21589,22855,24145,25359,26642,27836,28977,30114,31185,32273,33309,34357,35343,36341,37271,38166,39080,39957,40763,41573,42373,43087,43817,44569,45277,45932,46533,47215,47800,48384,48993,49513,50035,50547,51027,51502,51953,52434,52894,53285,53708,54107,54481,54871,55237,55576,55920,56257,56594,56895,57203,57484,57763,58040,58308,58554,58798,59029,59257,59465,59706,59871,60064,60264,60461,60627,60808,61018,61185,61335,61502,61663,61802,61946,62075,62207,62330,62458,62579,62704,62840,62966,63079,63190,63306,63404,63512,63598,63706,63775,63861, 0,0,0,0,0,3,5,17,44,104,193,353,540,793,1103,1517,1992,2507,3078,3693,4344,4999,5720,6449,7188,7957,8748,9534,10349,11144,11938,12756,13569,14360,15163,15983,16721,17533,18253,19043,19774,20478,21135,21777,22450,23038,23706,24318,24944,25479,26040,26572,27086,27609,28117,28569,29042,29467,29910,30322,30680,31084,31493,31880,32271,32627,32965,33316,33641,33958,34292,34608,34892,35211,35472,35730,35976,36221,36485,36722,36953,37164,37370,37573,37772,37961,38157,38355,38537,38711,38889,39051,39198,39357,39522,39661,39794,39934,40060,40163,40283,40401,40521,40634,40741,40838,40939,41057,41160,41254,41361,41451,41551,41639,41726,41802,41878,41960,42029,42100}; -} // namesapce detail } // namespace QuantLib diff --git a/ql/functional.hpp b/ql/functional.hpp index ff914c34295..4bb48692666 100644 --- a/ql/functional.hpp +++ b/ql/functional.hpp @@ -27,9 +27,7 @@ #include #include -namespace QuantLib { - - namespace ext { +namespace QuantLib::ext { /*! \deprecated Use std::function instead. Deprecated in version 1.36. @@ -60,7 +58,7 @@ namespace QuantLib { /*! \deprecated Use the std::placeholders namespace instead. Deprecated in version 1.36. */ - namespace [[deprecated("Use the std::placeholders namespace instead")]] placeholders { + namespace [[deprecated("Use the std::placeholders namespace instead")]] placeholders { // NOLINT(modernize-concat-nested-namespaces) using namespace std::placeholders; // NOLINT(misc-unused-using-decls) } @@ -76,8 +74,6 @@ namespace QuantLib { } -} - #endif diff --git a/ql/indexes/inflationindex.hpp b/ql/indexes/inflationindex.hpp index 18cb8cc419f..93243c4e95d 100644 --- a/ql/indexes/inflationindex.hpp +++ b/ql/indexes/inflationindex.hpp @@ -244,8 +244,7 @@ namespace QuantLib { }; - namespace detail { - namespace CPI { + namespace detail::CPI { // Returns either CPI::Flat or CPI::Linear depending on the combination of index and // CPI::InterpolationType. QuantLib::CPI::InterpolationType effectiveInterpolationType( @@ -256,7 +255,6 @@ namespace QuantLib { // effectively in CPI::Linear bool isInterpolated(const QuantLib::CPI::InterpolationType& type = QuantLib::CPI::AsIndex); } - } // inline diff --git a/ql/instrument.hpp b/ql/instrument.hpp index 833665bb0eb..db84d0fc3c4 100644 --- a/ql/instrument.hpp +++ b/ql/instrument.hpp @@ -187,7 +187,7 @@ namespace QuantLib { template inline T Instrument::result(const std::string& tag) const { calculate(); - std::map::const_iterator value = + auto value = additionalResults_.find(tag); QL_REQUIRE(value != additionalResults_.end(), tag << " not provided"); diff --git a/ql/instruments/assetswap.cpp b/ql/instruments/assetswap.cpp index c3465434cd0..47a05b030c4 100644 --- a/ql/instruments/assetswap.cpp +++ b/ql/instruments/assetswap.cpp @@ -221,7 +221,7 @@ namespace QuantLib { .withPaymentAdjustment(paymentAdjustment) .withSpreads(spread); - for (Leg::const_iterator i=legs_[1].begin(); icashflows(); @@ -257,7 +257,7 @@ namespace QuantLib { } QL_REQUIRE(!legs_[0].empty(), "empty bond leg"); - for (Leg::const_iterator i=legs_[0].begin(); ifirst->deepUpdate(); } update(); diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index 4af145db7d9..72b25ba111c 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -91,7 +91,7 @@ namespace QuantLib { legs_[0].push_back(createEquityCashFlow(schedule_, equityIndex_, nominal_, paymentCalendar_, paymentConvention_, paymentDelay_)); - for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i) + for (auto i = legs_[0].begin(); i < legs_[0].end(); ++i) registerWith(*i); switch (type_) { @@ -133,7 +133,7 @@ namespace QuantLib { legs_[1] = createInterestLeg( schedule_, interestRateIndex, nominal_, dayCounter_, margin_, gearing_, paymentCalendar_, paymentConvention_, paymentDelay_); - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); } @@ -162,7 +162,7 @@ namespace QuantLib { legs_[1] = createInterestLeg( schedule_, interestRateIndex, nominal_, dayCounter_, margin_, gearing_, paymentCalendar_, paymentConvention_, paymentDelay_); - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); } diff --git a/ql/instruments/floatfloatswap.cpp b/ql/instruments/floatfloatswap.cpp index 67048ab8dcd..b149e5dc72c 100644 --- a/ql/instruments/floatfloatswap.cpp +++ b/ql/instruments/floatfloatswap.cpp @@ -368,10 +368,10 @@ namespace QuantLib { nominal2_.push_back(nominal2_.back()); } - for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i) + for (auto i = legs_[0].begin(); i < legs_[0].end(); ++i) registerWith(*i); - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); switch (type_) { @@ -457,7 +457,7 @@ namespace QuantLib { } else { ext::shared_ptr cashflow = ext::dynamic_pointer_cast(leg1Coupons[i]); - std::vector::const_iterator j = + auto j = std::find(arguments->leg1PayDates.begin(), arguments->leg1PayDates.end(), cashflow->date()); QL_REQUIRE(j != arguments->leg1PayDates.end(), @@ -503,7 +503,7 @@ namespace QuantLib { } else { ext::shared_ptr cashflow = ext::dynamic_pointer_cast(leg2Coupons[i]); - std::vector::const_iterator j = + auto j = std::find(arguments->leg2PayDates.begin(), arguments->leg2PayDates.end(), cashflow->date()); QL_REQUIRE(j != arguments->leg2PayDates.end(), diff --git a/ql/instruments/impliedvolatility.hpp b/ql/instruments/impliedvolatility.hpp index cfcda72d6ff..1721badd5c2 100644 --- a/ql/instruments/impliedvolatility.hpp +++ b/ql/instruments/impliedvolatility.hpp @@ -28,9 +28,7 @@ #include #include -namespace QuantLib { - - namespace detail { +namespace QuantLib::detail { //! helper class for one-asset implied-volatility calculation /*! The passed engine must be linked to the passed quote (see, @@ -63,6 +61,4 @@ namespace QuantLib { } -} - #endif diff --git a/ql/instruments/nonstandardswap.cpp b/ql/instruments/nonstandardswap.cpp index 4c0cc7a0f75..b476e468cbe 100644 --- a/ql/instruments/nonstandardswap.cpp +++ b/ql/instruments/nonstandardswap.cpp @@ -210,7 +210,7 @@ namespace QuantLib { floatingNominal_.push_back(floatingNominal_.back()); } - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); switch (type_) { @@ -259,7 +259,7 @@ namespace QuantLib { } else { ext::shared_ptr cashflow = ext::dynamic_pointer_cast(fixedCoupons[i]); - std::vector::const_iterator j = + auto j = std::find(arguments->fixedPayDates.begin(), arguments->fixedPayDates.end(), cashflow->date()); QL_REQUIRE(j != arguments->fixedPayDates.end(), @@ -308,7 +308,7 @@ namespace QuantLib { } else { ext::shared_ptr cashflow = ext::dynamic_pointer_cast(floatingCoupons[i]); - std::vector::const_iterator j = std::find( + auto j = std::find( arguments->floatingPayDates.begin(), arguments->floatingPayDates.end(), cashflow->date()); QL_REQUIRE(j != arguments->floatingPayDates.end(), diff --git a/ql/instruments/zerocouponswap.cpp b/ql/instruments/zerocouponswap.cpp index 39cf0ed7370..0fd5919e173 100644 --- a/ql/instruments/zerocouponswap.cpp +++ b/ql/instruments/zerocouponswap.cpp @@ -62,7 +62,7 @@ namespace QuantLib { legs_[1].push_back(compoundedSubPeriodicCoupon(paymentDate_, startDate, maturityDate, baseNominal_, iborIndex_)); - for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i) + for (auto i = legs_[1].begin(); i < legs_[1].end(); ++i) registerWith(*i); switch (type_) { diff --git a/ql/math/integrals/exponentialintegrals.hpp b/ql/math/integrals/exponentialintegrals.hpp index eff7d4fbbe3..e52307b63cb 100644 --- a/ql/math/integrals/exponentialintegrals.hpp +++ b/ql/math/integrals/exponentialintegrals.hpp @@ -30,27 +30,23 @@ #define M_EULER_MASCHERONI 0.5772156649015328606065121 #endif -namespace QuantLib { - /*! References: - - B. Rowe et al: GALSIM: The modular galaxy image simulation toolkit - https://arxiv.org/abs/1407.7676 - - V. Pegoraro, P. Slusallek: - On the Evaluation of the Complex-Valued Exponential Integral - https://www.sci.utah.edu/~vpegorar/research/2011_JGT.pdf - - */ +/*! References: + B. Rowe et al: GALSIM: The modular galaxy image simulation toolkit + https://arxiv.org/abs/1407.7676 + V. Pegoraro, P. Slusallek: + On the Evaluation of the Complex-Valued Exponential Integral + https://www.sci.utah.edu/~vpegorar/research/2011_JGT.pdf +*/ +namespace QuantLib::ExponentialIntegral { + + Real Si(Real x); + Real Ci(Real x); - namespace ExponentialIntegral { - Real Si(Real x); - Real Ci(Real x); + std::complex Ci(const std::complex& z); + std::complex Si(const std::complex& z); + std::complex E1(const std::complex& z); + std::complex Ei(const std::complex& z); - std::complex Ci(const std::complex& z); - std::complex Si(const std::complex& z); - std::complex E1(const std::complex& z); - std::complex Ei(const std::complex& z); - } } #endif diff --git a/ql/math/interpolations/xabrinterpolation.hpp b/ql/math/interpolations/xabrinterpolation.hpp index 035b86ad7dd..d2f3516e450 100644 --- a/ql/math/interpolations/xabrinterpolation.hpp +++ b/ql/math/interpolations/xabrinterpolation.hpp @@ -45,9 +45,7 @@ #include #include -namespace QuantLib { - -namespace detail { +namespace QuantLib::detail { template class XABRCoeffHolder { public: @@ -323,7 +321,6 @@ class XABRInterpolationImpl final : public Interpolation::templateImpl, VolatilityType volatilityType_; }; -} // namespace detail } // namespace QuantLib #endif diff --git a/ql/math/optimization/lmdif.cpp b/ql/math/optimization/lmdif.cpp index 61f17f813dd..2a8e2b2cdfa 100644 --- a/ql/math/optimization/lmdif.cpp +++ b/ql/math/optimization/lmdif.cpp @@ -65,8 +65,7 @@ or guarantee. #include #include -namespace QuantLib { - namespace MINPACK { +namespace QuantLib::MINPACK { #define BUG 0 /* resolution of arithmetic */ double MACHEP = 1.2e-16; @@ -1668,7 +1667,6 @@ if(nprint > 0) */ } } -} /************************fdjac2.c*************************/ diff --git a/ql/math/optimization/lmdif.hpp b/ql/math/optimization/lmdif.hpp index 6b6d18d8c77..f22eec0eb9c 100644 --- a/ql/math/optimization/lmdif.hpp +++ b/ql/math/optimization/lmdif.hpp @@ -28,9 +28,7 @@ #include #include -namespace QuantLib { - - namespace MINPACK { +namespace QuantLib::MINPACK { typedef std::functionlayout()->size() == a.size(), "inconsistent array dimensions"); - const std::vector