Skip to content

Commit

Permalink
Automated fixes by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and lballabio committed Jul 24, 2024
1 parent 72a7e1a commit 5217c00
Show file tree
Hide file tree
Showing 67 changed files with 109 additions and 190 deletions.
6 changes: 1 addition & 5 deletions ql/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <boost/any.hpp>
#endif

namespace QuantLib {

namespace ext {
namespace QuantLib::ext {

#if defined(QL_USE_STD_ANY)
using std::any; // NOLINT(misc-unused-using-decls)
Expand All @@ -46,6 +44,4 @@ namespace QuantLib {

}

}

#endif
6 changes: 1 addition & 5 deletions ql/cashflows/cashflowvectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#include <ql/indexes/iborindex.hpp>
#include <ql/time/schedule.hpp>

namespace QuantLib {

namespace detail {
namespace QuantLib::detail {

Rate effectiveFixedRate(const std::vector<Spread>& spreads,
const std::vector<Rate>& caps,
Expand All @@ -55,5 +53,3 @@ namespace QuantLib {
}

}

}
2 changes: 1 addition & 1 deletion ql/cashflows/timebasket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace QuantLib {
Real value = j.second;
Date pDate = Null<Date>(), nDate = Null<Date>();

std::vector<Date>::const_iterator bi =
auto bi =
std::lower_bound(sbuckets.begin(), sbuckets.end(), date);

if (bi == sbuckets.end())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, std::complex<Real> >::const_iterator position = fLookupTable_.find(location);
auto position = fLookupTable_.find(location);
if (position != fLookupTable_.end()) {
std::complex<Real> value = position->second;
fMinusN[offset-1] = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace QuantLib {
// omega_tilde calls itself recursivly, use lookup map to avoid extreme slowdown when k large
std::complex<Real> omega_kp1 = 0.0;

std::map<Size, std::complex<Real> >::const_iterator position = omegaTildeLookupTable_.find(k+1);
auto position = omegaTildeLookupTable_.find(k+1);

if (position != omegaTildeLookupTable_.end()) {
std::complex<Real> value = position->second;
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/commoditycurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace QuantLib {

dates_.clear();
data_.clear();
for (std::map<Date, Real>::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);
}
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/commoditycurve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace QuantLib {
const ext::shared_ptr<ExchangeContracts>& 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)
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/commoditytype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace QuantLib {

CommodityType::CommodityType(const std::string& name,
const std::string& code) {
std::map<std::string, ext::shared_ptr<CommodityType::Data> >::const_iterator i = commodityTypes_.find(code);
auto i = commodityTypes_.find(code);
if (i != commodityTypes_.end())
data_ = i->second;
else {
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/energybasisswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/energycommodity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommodityUnitCost>(&i->second) != nullptr) {
Real value =
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/energyfuture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/energyvanillaswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/paymentterm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace QuantLib {
PaymentTerm::EventType eventType,
Integer offsetDays,
const Calendar& calendar) {
std::map<std::string, ext::shared_ptr<PaymentTerm::Data> >::const_iterator i = paymentTerms_.find(name);
auto i = paymentTerms_.find(name);
if (i != paymentTerms_.end())
data_ = i->second;
else {
Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/commodities/unitofmeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ namespace QuantLib {
UnitOfMeasure::UnitOfMeasure(const std::string& name,
const std::string& code,
UnitOfMeasure::Type unitType) {
std::map<std::string,
ext::shared_ptr<UnitOfMeasure::Data> >::const_iterator i =
auto i =
unitsOfMeasure_.find(name);
if (i != unitsOfMeasure_.end()) {
data_ = i->second;
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/credit/binomiallossmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ namespace QuantLib {

if(perc == 1.) return dist.rbegin()->first;
if(perc == 0.) return dist.begin()->first;
std::map<Real, Probability>::const_iterator itdist = dist.begin();
auto itdist = dist.begin();
while (itdist->second <= perc) ++itdist;
Real valPlus = itdist->second;
Real xPlus = itdist->first;
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/credit/randomdefaultlatentmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ namespace QuantLib {
events[iEvt].nameIdx));
}
if(namesDefaulting.size() >= n) {
std::map<unsigned short, unsigned short>::const_iterator
auto
itdefs = namesDefaulting.begin();
// locate nth default in time:
std::advance(itdefs, n-1);
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/math/piecewiseintegral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace QuantLib {
eps_(avoidCriticalPoints ? (1.0 + QL_EPSILON) : 1.0) {

std::sort(criticalPoints_.begin(), criticalPoints_.end());
std::vector<Real>::const_iterator end =
auto end =
std::unique(criticalPoints_.begin(), criticalPoints_.end(),
static_cast<bool (*)(Real, Real)>(close_enough));
criticalPoints_.resize(end - criticalPoints_.begin());
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/models/squarerootclvmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/swaptions/irregularswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/variancegamma/fftengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace QuantLib {
std::complex<Real> 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;

Expand Down
4 changes: 1 addition & 3 deletions ql/experimental/volatility/noarbsabr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand Down
4 changes: 1 addition & 3 deletions ql/experimental/volatility/noarbsabrabsprobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

#include <ql/experimental/volatility/noarbsabr.hpp>

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,
Expand Down Expand Up @@ -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
8 changes: 2 additions & 6 deletions ql/functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
#include <ql/qldefines.hpp>
#include <functional>

namespace QuantLib {

namespace ext {
namespace QuantLib::ext {

/*! \deprecated Use std::function instead.
Deprecated in version 1.36.
Expand Down Expand Up @@ -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)
}

Expand All @@ -76,8 +74,6 @@ namespace QuantLib {

}

}


#endif

4 changes: 1 addition & 3 deletions ql/indexes/inflationindex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -256,7 +255,6 @@ namespace QuantLib {
// effectively in CPI::Linear
bool isInterpolated(const QuantLib::CPI::InterpolationType& type = QuantLib::CPI::AsIndex);
}
}


// inline
Expand Down
2 changes: 1 addition & 1 deletion ql/instrument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ namespace QuantLib {
template <class T>
inline T Instrument::result(const std::string& tag) const {
calculate();
std::map<std::string, ext::any>::const_iterator value =
auto value =
additionalResults_.find(tag);
QL_REQUIRE(value != additionalResults_.end(),
tag << " not provided");
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/assetswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace QuantLib {
.withPaymentAdjustment(paymentAdjustment)
.withSpreads(spread);

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);

const Leg& bondLeg = bond_->cashflows();
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace QuantLib {
}

QL_REQUIRE(!legs_[0].empty(), "empty bond leg");
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);

if (payBondCoupon) {
Expand Down
2 changes: 1 addition & 1 deletion ql/instruments/compositeinstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace QuantLib {
}

void CompositeInstrument::deepUpdate() {
for (const_iterator i=components_.begin(); i!=components_.end(); ++i) {
for (auto i=components_.begin(); i!=components_.end(); ++i) {
i->first->deepUpdate();
}
update();
Expand Down
6 changes: 3 additions & 3 deletions ql/instruments/equitytotalreturnswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace QuantLib {
legs_[1] = createInterestLeg<IborIndex, IborLeg>(
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);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ namespace QuantLib {
legs_[1] = createInterestLeg<OvernightIndex, OvernightLeg>(
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);
}

Expand Down
8 changes: 4 additions & 4 deletions ql/instruments/floatfloatswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -457,7 +457,7 @@ namespace QuantLib {
} else {
ext::shared_ptr<CashFlow> cashflow =
ext::dynamic_pointer_cast<CashFlow>(leg1Coupons[i]);
std::vector<Date>::const_iterator j =
auto j =
std::find(arguments->leg1PayDates.begin(),
arguments->leg1PayDates.end(), cashflow->date());
QL_REQUIRE(j != arguments->leg1PayDates.end(),
Expand Down Expand Up @@ -503,7 +503,7 @@ namespace QuantLib {
} else {
ext::shared_ptr<CashFlow> cashflow =
ext::dynamic_pointer_cast<CashFlow>(leg2Coupons[i]);
std::vector<Date>::const_iterator j =
auto j =
std::find(arguments->leg2PayDates.begin(),
arguments->leg2PayDates.end(), cashflow->date());
QL_REQUIRE(j != arguments->leg2PayDates.end(),
Expand Down
6 changes: 1 addition & 5 deletions ql/instruments/impliedvolatility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
#include <ql/quotes/simplequote.hpp>
#include <ql/processes/blackscholesprocess.hpp>

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,
Expand Down Expand Up @@ -63,6 +61,4 @@ namespace QuantLib {

}

}

#endif
Loading

0 comments on commit 5217c00

Please sign in to comment.