From af365f0a188e924d18ee62021bc1978d7ad22015 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:07:28 +0000 Subject: [PATCH] Automated fixes by clang-tidy --- ql/experimental/basismodels/swaptioncfs.hpp | 18 +++++----- ql/experimental/math/fireflyalgorithm.hpp | 2 +- .../math/hybridsimulatedannealing.hpp | 3 +- .../math/hybridsimulatedannealingfunctors.hpp | 36 +++++++++---------- ql/experimental/math/isotropicrandomwalk.hpp | 8 ++--- .../math/particleswarmoptimization.hpp | 24 ++++++------- .../variancegamma/variancegammamodel.cpp | 5 +-- ql/instruments/bond.cpp | 7 ++-- ql/math/integrals/trapezoidintegral.hpp | 8 ++--- ql/math/interpolations/cubicinterpolation.hpp | 2 +- .../interpolations/lagrangeinterpolation.hpp | 2 +- ql/math/linearleastsquaresregression.hpp | 2 +- ql/math/sampledcurve.hpp | 4 +-- ql/methods/montecarlo/lsmbasissystem.cpp | 4 +-- ql/models/equity/batesmodel.cpp | 5 +-- ql/models/equity/gjrgarchmodel.cpp | 5 +-- ql/models/equity/hestonmodel.cpp | 5 +-- .../forward/mcvarianceswapengine.hpp | 2 +- .../vanilla/mceuropeanengine.hpp | 2 +- .../inflation/inflationhelpers.cpp | 9 ++--- ql/timeseries.hpp | 4 +-- ql/utilities/steppingiterator.hpp | 4 +-- test-suite/digitaloption.cpp | 9 ++--- test-suite/doublebinaryoption.cpp | 5 +-- 24 files changed, 92 insertions(+), 83 deletions(-) diff --git a/ql/experimental/basismodels/swaptioncfs.hpp b/ql/experimental/basismodels/swaptioncfs.hpp index 77a76101098..f13232a68ed 100644 --- a/ql/experimental/basismodels/swaptioncfs.hpp +++ b/ql/experimental/basismodels/swaptioncfs.hpp @@ -39,9 +39,9 @@ namespace QuantLib { std::vector floatWeights_; public: - inline const Leg& floatLeg() const { return floatLeg_; } - inline const std::vector& floatTimes() const { return floatTimes_; } - inline const std::vector& floatWeights() const { return floatWeights_; } + const Leg& floatLeg() const { return floatLeg_; } + const std::vector& floatTimes() const { return floatTimes_; } + const std::vector& floatWeights() const { return floatWeights_; } IborLegCashFlows(const Leg& iborLeg, const Handle& discountCurve, bool contTenorSpread = true); @@ -65,10 +65,10 @@ namespace QuantLib { SwapCashFlows() = default; ; // allow default constructor which does nothing // inspectors - inline const Leg& fixedLeg() const { return fixedLeg_; } - inline const std::vector& fixedTimes() const { return fixedTimes_; } - inline const std::vector& fixedWeights() const { return fixedWeights_; } - inline const std::vector& annuityWeights() const { return annuityWeights_; } + const Leg& fixedLeg() const { return fixedLeg_; } + const std::vector& fixedTimes() const { return fixedTimes_; } + const std::vector& fixedWeights() const { return fixedWeights_; } + const std::vector& annuityWeights() const { return annuityWeights_; } }; @@ -84,8 +84,8 @@ namespace QuantLib { SwaptionCashFlows() = default; ; // allow default constructor which does nothing // inspectors - inline ext::shared_ptr swaption() const { return swaption_; } - inline const std::vector& exerciseTimes() const { return exerciseTimes_; } + ext::shared_ptr swaption() const { return swaption_; } + const std::vector& exerciseTimes() const { return exerciseTimes_; } }; diff --git a/ql/experimental/math/fireflyalgorithm.hpp b/ql/experimental/math/fireflyalgorithm.hpp index 22f23fdc6c6..58fdf124078 100644 --- a/ql/experimental/math/fireflyalgorithm.hpp +++ b/ql/experimental/math/fireflyalgorithm.hpp @@ -120,7 +120,7 @@ namespace QuantLib { std::vector *xI_; virtual Real intensityImpl(Real valueX, Real valueY, Real distance) = 0; - inline Real distance(const Array& x, const Array& y) const { + Real distance(const Array& x, const Array& y) const { Real d = 0.0; for (Size i = 0; i < N_; i++) { Real diff = x[i] - y[i]; diff --git a/ql/experimental/math/hybridsimulatedannealing.hpp b/ql/experimental/math/hybridsimulatedannealing.hpp index d6a6b989603..d8575893b92 100644 --- a/ql/experimental/math/hybridsimulatedannealing.hpp +++ b/ql/experimental/math/hybridsimulatedannealing.hpp @@ -30,6 +30,7 @@ Mathl. Comput. Modelling, 967-973, 1989 #include #include #include +#include #include namespace QuantLib { @@ -97,7 +98,7 @@ namespace QuantLib { localOptimizer_(localOptimizer), optimizeScheme_(localOptimizer != nullptr ? optimizeScheme : NoLocalOptimize) { if (!localOptimizer) - localOptimizer.reset(new LevenbergMarquardt); + localOptimizer = ext::make_shared(); } EndCriteria::Type minimize(Problem& P, const EndCriteria& endCriteria) override; diff --git a/ql/experimental/math/hybridsimulatedannealingfunctors.hpp b/ql/experimental/math/hybridsimulatedannealingfunctors.hpp index 805892e1b6d..fa2938a7159 100644 --- a/ql/experimental/math/hybridsimulatedannealingfunctors.hpp +++ b/ql/experimental/math/hybridsimulatedannealingfunctors.hpp @@ -46,7 +46,7 @@ namespace QuantLib explicit SamplerLogNormal(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed), distribution_(0.0, 1.0) {}; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); for (Size i = 0; i < currentPoint.size(); i++) @@ -67,7 +67,7 @@ namespace QuantLib explicit SamplerGaussian(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed), distribution_(0.0, 1.0) {}; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); for (Size i = 0; i < currentPoint.size(); i++) @@ -92,7 +92,7 @@ namespace QuantLib : generator_(seed), distribution_(0.0, 1.0), lower_(std::move(lower)), upper_(std::move(upper)){}; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); for (Size i = 0; i < currentPoint.size(); i++){ @@ -126,7 +126,7 @@ namespace QuantLib : generator_(seed), distribution_(0.0, 1.0), lower_(std::move(lower)), upper_(std::move(upper)){}; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); for (Size i = 0; i < currentPoint.size(); i++){ @@ -158,7 +158,7 @@ namespace QuantLib explicit SamplerCauchy(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed), distribution_(0.0, 1.0) {}; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); for (Size i = 0; i < currentPoint.size(); i++) @@ -183,7 +183,7 @@ namespace QuantLib QL_REQUIRE(lower_.size() == upper_.size(), "Incompatible input"); }; - inline void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { + void operator()(Array &newPoint, const Array ¤tPoint, const Array &temp) { QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == lower_.size(), "Incompatible input"); QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input"); @@ -210,7 +210,7 @@ namespace QuantLib optimizer will be able to escape a local optimum. */ struct ProbabilityAlwaysDownhill { - inline bool operator()(Real currentValue, Real newValue, const Array &temp) { + bool operator()(Real currentValue, Real newValue, const Array &temp) { return currentValue > newValue; //return true if new value is lower than old value } }; @@ -224,7 +224,7 @@ namespace QuantLib public: explicit ProbabilityBoltzmann(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed) {}; - inline bool operator()(Real currentValue, Real newValue, const Array &temp) { + bool operator()(Real currentValue, Real newValue, const Array &temp) { Real temperature = *std::max_element(temp.begin(), temp.end()); return (1.0 / (1.0 + exp((newValue - currentValue) / temperature))) > distribution_(generator_); } @@ -241,7 +241,7 @@ namespace QuantLib public: explicit ProbabilityBoltzmannDownhill(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed) {}; - inline bool operator()(Real currentValue, Real newValue, const Array &temp) { + bool operator()(Real currentValue, Real newValue, const Array &temp) { if (newValue < currentValue) return true; Real mTemperature = *std::max_element(temp.begin(), temp.end()); @@ -258,7 +258,7 @@ namespace QuantLib public: TemperatureBoltzmann(Real initialTemp, Size dimension) : initialTemp_(dimension, initialTemp) {} - inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { + void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input"); QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input"); for (Size i = 0; i < initialTemp_.size(); i++) @@ -274,7 +274,7 @@ namespace QuantLib public: TemperatureCauchy(Real initialTemp, Size dimension) : initialTemp_(dimension, initialTemp) {} - inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { + void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input"); QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input"); for (Size i = 0; i < initialTemp_.size(); i++) @@ -289,7 +289,7 @@ namespace QuantLib TemperatureCauchy1D(Real initialTemp, Size dimension) : inverseN_(1.0 / dimension), initialTemp_(dimension, initialTemp) {} - inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { + void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input"); QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input"); for (Size i = 0; i < initialTemp_.size(); i++) @@ -304,7 +304,7 @@ namespace QuantLib public: TemperatureExponential(Real initialTemp, Size dimension, Real power = 0.95) : initialTemp_(dimension, initialTemp), power_(power) {} - inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { + void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input"); QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input"); for (Size i = 0; i < initialTemp_.size(); i++) @@ -326,7 +326,7 @@ namespace QuantLib for (Size i = 0; i < initialTemp_.size(); i++) exponent_[i] = -std::log(finalTemp_[i] / initialTemp_[i])*coeff; } - inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { + void operator()(Array &newTemp, const Array &currTemp, const Array &steps) { QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input"); QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input"); for (Size i = 0; i < initialTemp_.size(); i++) @@ -342,8 +342,8 @@ namespace QuantLib struct ReannealingTrivial { ReannealingTrivial() = default; ; - inline void setProblem(Problem &P) {}; - inline void operator()(Array & steps, const Array ¤tPoint, + void setProblem(Problem &P) {}; + void operator()(Array & steps, const Array ¤tPoint, Real aCurrentValue, const Array & currTemp) {}; }; //! Reannealing Finite Difference @@ -375,8 +375,8 @@ namespace QuantLib } } } - inline void setProblem(Problem &P) { problem_ = &P; }; - inline void operator()(Array & steps, const Array ¤tPoint, + void setProblem(Problem &P) { problem_ = &P; }; + void operator()(Array & steps, const Array ¤tPoint, Real currentValue, const Array & currTemp) { QL_REQUIRE(currTemp.size() == N_, "Incompatible input"); QL_REQUIRE(steps.size() == N_, "Incompatible input"); diff --git a/ql/experimental/math/isotropicrandomwalk.hpp b/ql/experimental/math/isotropicrandomwalk.hpp index 72d6fdcdb56..5883aa879ff 100644 --- a/ql/experimental/math/isotropicrandomwalk.hpp +++ b/ql/experimental/math/isotropicrandomwalk.hpp @@ -55,7 +55,7 @@ namespace QuantLib { QL_REQUIRE(dim_ == weights_.size(), "Invalid weights"); } template - inline void nextReal(InputIterator first) { + void nextReal(InputIterator first) { Real radius = distribution_(engine_); Array::const_iterator weight = weights_.begin(); if (dim_ > 1) { @@ -76,11 +76,11 @@ namespace QuantLib { *first = radius*(*weight); } } - inline void setDimension(Size dim) { + void setDimension(Size dim) { dim_ = dim; weights_ = Array(dim, 1.0); } - inline void setDimension(Size dim, const Array& weights) { + void setDimension(Size dim, const Array& weights) { QL_REQUIRE(dim == weights.size(), "Invalid weights"); dim_ = dim; weights_ = weights; @@ -90,7 +90,7 @@ namespace QuantLib { but if the limits are provided, they are used to rescale the sphere so as to make it to an ellipsoid, with different radius in different dimensions. */ - inline void setDimension(Size dim, + void setDimension(Size dim, const Array& lowerBound, const Array& upperBound) { QL_REQUIRE(dim == lowerBound.size(), "Incompatible dimension and lower bound"); diff --git a/ql/experimental/math/particleswarmoptimization.hpp b/ql/experimental/math/particleswarmoptimization.hpp index 6a9add5eeb5..17d3783e183 100644 --- a/ql/experimental/math/particleswarmoptimization.hpp +++ b/ql/experimental/math/particleswarmoptimization.hpp @@ -156,11 +156,11 @@ namespace QuantLib { */ class TrivialInertia : public ParticleSwarmOptimization::Inertia { public: - inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { + void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { c0_ = c0; M_ = M; } - inline void setValues() override { + void setValues() override { for (Size i = 0; i < M_; i++) { (*V_)[i] *= c0_; } @@ -181,11 +181,11 @@ namespace QuantLib { : threshold_(threshold), rng_(seed) { QL_REQUIRE(threshold_ >= 0.0 && threshold_ < 1.0, "Threshold must be a Real in [0, 1)"); } - inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { + void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { M_ = M; c0_ = c0; } - inline void setValues() override { + void setValues() override { for (Size i = 0; i < M_; i++) { Real val = c0_*(threshold_ + (1.0 - threshold_)*rng_.nextReal()); (*V_)[i] *= val; @@ -208,13 +208,13 @@ namespace QuantLib { : threshold_(threshold) { QL_REQUIRE(threshold_ >= 0.0 && threshold_ < 1.0, "Threshold must be a Real in [0, 1)"); } - inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { + void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { N_ = N; c0_ = c0; iteration_ = 0; maxIterations_ = endCriteria.maxIterations(); } - inline void setValues() override { + void setValues() override { Real c0 = c0_*(threshold_ + (1.0 - threshold_)*(maxIterations_ - iteration_) / maxIterations_); for (Size i = 0; i < M_; i++) { (*V_)[i] *= c0; @@ -235,7 +235,7 @@ namespace QuantLib { AdaptiveInertia(Real minInertia, Real maxInertia, Size sh = 5, Size sl = 2) :minInertia_(minInertia), maxInertia_(maxInertia), sh_(sh), sl_(sl) {}; - inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { + void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { M_ = M; c0_ = c0; adaptiveCounter = 0; @@ -266,13 +266,13 @@ namespace QuantLib { :rng_(seed), generator_(seed), flight_(generator_, LevyFlightDistribution(1.0, alpha), 1, Array(1, 1.0), seed), threshold_(threshold) {}; - inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { + void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override { M_ = M; N_ = N; c0_ = c0; adaptiveCounter_ = std::vector(M_, 0); } - inline void setValues() override { + void setValues() override { for (Size i = 0; i < M_; i++) { if ((*pBF_)[i] < personalBestF_[i]) { personalBestF_[i] = (*pBF_)[i]; @@ -345,8 +345,8 @@ namespace QuantLib { */ class GlobalTopology : public ParticleSwarmOptimization::Topology { public: - inline void setSize(Size M) override { M_ = M; } - inline void findSocialBest() override { + void setSize(Size M) override { M_ = M; } + void findSocialBest() override { Real bestF = (*pBF_)[0]; Size bestP = 0; for (Size i = 1; i < M_; i++) { @@ -378,7 +378,7 @@ namespace QuantLib { KNeighbors(Size K = 1) :K_(K) { QL_REQUIRE(K > 0, "Neighbors need to be larger than 0"); } - inline void setSize(Size M) override { + void setSize(Size M) override { M_ = M; QL_ENSURE(K_ < M, "Number of neighbors need to be smaller than total particles in swarm"); } diff --git a/ql/experimental/variancegamma/variancegammamodel.cpp b/ql/experimental/variancegamma/variancegammamodel.cpp index 1e9201788d3..95358efa451 100644 --- a/ql/experimental/variancegamma/variancegammamodel.cpp +++ b/ql/experimental/variancegamma/variancegammamodel.cpp @@ -19,6 +19,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. #include #include +#include namespace QuantLib { @@ -40,10 +41,10 @@ namespace QuantLib { } void VarianceGammaModel::generateArguments() { - process_.reset(new VarianceGammaProcess(process_->s0(), + process_ = ext::make_shared(process_->s0(), process_->dividendYield(), process_->riskFreeRate(), - sigma(), nu(), theta())); + sigma(), nu(), theta()); } } diff --git a/ql/instruments/bond.cpp b/ql/instruments/bond.cpp index a565f3775b2..1b3c505c3e8 100644 --- a/ql/instruments/bond.cpp +++ b/ql/instruments/bond.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -326,10 +327,10 @@ namespace QuantLib { Real amount = (R/100.0)*(notionals_[i-1]-notionals_[i]); ext::shared_ptr payment; if (i < notionalSchedule_.size()-1) - payment.reset(new AmortizingPayment(amount, - notionalSchedule_[i])); + payment = ext::make_shared(amount, + notionalSchedule_[i]); else - payment.reset(new Redemption(amount, notionalSchedule_[i])); + payment = ext::make_shared(amount, notionalSchedule_[i]); cashflows_.push_back(payment); redemptions_.push_back(payment); } diff --git a/ql/math/integrals/trapezoidintegral.hpp b/ql/math/integrals/trapezoidintegral.hpp index d8fbdb1dba7..ee2e4a1e503 100644 --- a/ql/math/integrals/trapezoidintegral.hpp +++ b/ql/math/integrals/trapezoidintegral.hpp @@ -82,7 +82,7 @@ namespace QuantLib { // Integration policies struct Default { - inline static Real integrate(const std::function& f, + static Real integrate(const std::function& f, Real a, Real b, Real I, @@ -95,11 +95,11 @@ namespace QuantLib { sum += f(x); return (I + dx*sum)/2.0; } - inline static Size nbEvalutions(){ return 2;} + static Size nbEvalutions(){ return 2;} }; struct MidPoint { - inline static Real integrate(const std::function& f, + static Real integrate(const std::function& f, Real a, Real b, Real I, @@ -113,7 +113,7 @@ namespace QuantLib { sum += f(x) + f(x+D); return (I + dx*sum)/3.0; } - inline static Size nbEvalutions(){ return 3;} + static Size nbEvalutions(){ return 3;} }; } diff --git a/ql/math/interpolations/cubicinterpolation.hpp b/ql/math/interpolations/cubicinterpolation.hpp index 0bb40efbfd4..d4e01b95ed0 100644 --- a/ql/math/interpolations/cubicinterpolation.hpp +++ b/ql/math/interpolations/cubicinterpolation.hpp @@ -787,7 +787,7 @@ namespace QuantLib { mutable std::vector dx_, S_; mutable TridiagonalOperator L_; - inline Real cubicInterpolatingPolynomialDerivative( + Real cubicInterpolatingPolynomialDerivative( Real a, Real b, Real c, Real d, Real u, Real v, Real w, Real z, Real x) const { return (-((((a-c)*(b-c)*(c-x)*z-(a-d)*(b-d)*(d-x)*w)*(a-x+b-x) diff --git a/ql/math/interpolations/lagrangeinterpolation.hpp b/ql/math/interpolations/lagrangeinterpolation.hpp index bc963898852..b31aa07ff53 100644 --- a/ql/math/interpolations/lagrangeinterpolation.hpp +++ b/ql/math/interpolations/lagrangeinterpolation.hpp @@ -112,7 +112,7 @@ namespace QuantLib { private: template - inline Real _value(const Iterator& yBegin, Real x) const { + Real _value(const Iterator& yBegin, Real x) const { const Real eps = 10*QL_EPSILON*std::abs(x); const auto iter = std::lower_bound( diff --git a/ql/math/linearleastsquaresregression.hpp b/ql/math/linearleastsquaresregression.hpp index ed9d83aadb2..821ffc244f1 100644 --- a/ql/math/linearleastsquaresregression.hpp +++ b/ql/math/linearleastsquaresregression.hpp @@ -40,7 +40,7 @@ namespace QuantLib { public: explicit LinearFct(Size i) : i_(i) {} - inline Real operator()(const Container& x) const { + Real operator()(const Container& x) const { return x[i_]; } diff --git a/ql/math/sampledcurve.hpp b/ql/math/sampledcurve.hpp index fc756104596..0b747466c76 100644 --- a/ql/math/sampledcurve.hpp +++ b/ql/math/sampledcurve.hpp @@ -138,14 +138,14 @@ namespace QuantLib { QL_DEPRECATED_DISABLE_WARNING template - inline const SampledCurve& transform(T x) { + const SampledCurve& transform(T x) { std::transform(values_.begin(), values_.end(), values_.begin(), x); return *this; } template - inline const SampledCurve& transformGrid(T x) { + const SampledCurve& transformGrid(T x) { std::transform(grid_.begin(), grid_.end(), grid_.begin(), x); return *this; diff --git a/ql/methods/montecarlo/lsmbasissystem.cpp b/ql/methods/montecarlo/lsmbasissystem.cpp index 398a281b71a..fb2e0c0866a 100644 --- a/ql/methods/montecarlo/lsmbasissystem.cpp +++ b/ql/methods/montecarlo/lsmbasissystem.cpp @@ -41,7 +41,7 @@ namespace QuantLib { class MonomialFct { public: explicit MonomialFct(Size order): order_(order) {} - inline Real operator()(const Real x) const { + Real operator()(const Real x) const { Real ret = 1.0; for(Size i=0; i +#include namespace QuantLib { @@ -36,11 +37,11 @@ namespace QuantLib { } void BatesModel::generateArguments() { - process_.reset(new BatesProcess( + process_ = ext::make_shared( process_->riskFreeRate(), process_->dividendYield(), process_->s0(), v0(), kappa(), theta(), sigma(), rho(), - lambda(), nu(), delta())); + lambda(), nu(), delta()); } BatesDetJumpModel::BatesDetJumpModel( diff --git a/ql/models/equity/gjrgarchmodel.cpp b/ql/models/equity/gjrgarchmodel.cpp index 5abf9c1ef8d..4d8a33b0d5d 100644 --- a/ql/models/equity/gjrgarchmodel.cpp +++ b/ql/models/equity/gjrgarchmodel.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace QuantLib { @@ -65,13 +66,13 @@ namespace QuantLib { } void GJRGARCHModel::generateArguments() { - process_.reset(new GJRGARCHProcess(process_->riskFreeRate(), + process_ = ext::make_shared(process_->riskFreeRate(), process_->dividendYield(), process_->s0(), v0(), omega(), alpha(), beta(), gamma(), lambda(), - process_->daysPerYear())); + process_->daysPerYear()); } } diff --git a/ql/models/equity/hestonmodel.cpp b/ql/models/equity/hestonmodel.cpp index b7330d168f5..d7f6f423220 100644 --- a/ql/models/equity/hestonmodel.cpp +++ b/ql/models/equity/hestonmodel.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace QuantLib { @@ -42,11 +43,11 @@ namespace QuantLib { } void HestonModel::generateArguments() { - process_.reset(new HestonProcess(process_->riskFreeRate(), + process_ = ext::make_shared(process_->riskFreeRate(), process_->dividendYield(), process_->s0(), v0(), kappa(), theta(), - sigma(), rho())); + sigma(), rho()); } } diff --git a/ql/pricingengines/forward/mcvarianceswapengine.hpp b/ql/pricingengines/forward/mcvarianceswapengine.hpp index 6d2f917e195..33dc5af06aa 100644 --- a/ql/pricingengines/forward/mcvarianceswapengine.hpp +++ b/ql/pricingengines/forward/mcvarianceswapengine.hpp @@ -329,7 +329,7 @@ namespace QuantLib { inline Real VariancePathPricer::operator()(const Path& path) const { - QL_REQUIRE(path.length() > 0, "the path cannot be empty"); + QL_REQUIRE(!path.empty(), "the path cannot be empty"); Time t0 = path.timeGrid().front(); Time t = path.timeGrid().back(); Time dt = path.timeGrid().dt(0); diff --git a/ql/pricingengines/vanilla/mceuropeanengine.hpp b/ql/pricingengines/vanilla/mceuropeanengine.hpp index f1ea2cfc6e1..3d774801c51 100644 --- a/ql/pricingengines/vanilla/mceuropeanengine.hpp +++ b/ql/pricingengines/vanilla/mceuropeanengine.hpp @@ -252,7 +252,7 @@ namespace QuantLib { } inline Real EuropeanPathPricer::operator()(const Path& path) const { - QL_REQUIRE(path.length() > 0, "the path cannot be empty"); + QL_REQUIRE(!path.empty(), "the path cannot be empty"); return payoff_(path.back()) * discount_; } diff --git a/ql/termstructures/inflation/inflationhelpers.cpp b/ql/termstructures/inflation/inflationhelpers.cpp index cce9c42cb1b..7ea04500768 100644 --- a/ql/termstructures/inflation/inflationhelpers.cpp +++ b/ql/termstructures/inflation/inflationhelpers.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -97,10 +98,10 @@ namespace QuantLib { Real nominal = 1000000.0; // has to be something but doesn't matter what Date start = nominalTermStructure_->referenceDate(); - zciis_.reset(new ZeroCouponInflationSwap(Swap::Payer, nominal, start, + zciis_ = ext::make_shared(Swap::Payer, nominal, start, maturity_, calendar_, paymentConvention_, dayCounter_, K, // fixed side & fixed rate - new_zii, swapObsLag_, observationInterpolation_)); + new_zii, swapObsLag_, observationInterpolation_); // Because very simple instrument only takes // standard discounting swap engine. zciis_->setPricingEngine( @@ -191,11 +192,11 @@ namespace QuantLib { Rate fixedRate = quote()->value(); Real nominal = 1000000.0; // has to be something but doesn't matter what - yyiis_.reset(new YearOnYearInflationSwap( + yyiis_ = ext::make_shared( Swap::Payer, nominal, fixedSchedule, fixedRate, dayCounter_, yoySchedule, new_yii, swapObsLag_, spread, dayCounter_, calendar_, // inflation index does not have a calendar - paymentConvention_)); + paymentConvention_); // The instrument takes a standard discounting swap engine. // The inflation-related work is done by the coupons. diff --git a/ql/timeseries.hpp b/ql/timeseries.hpp index b5e1f7d896b..9e9eef98e8f 100644 --- a/ql/timeseries.hpp +++ b/ql/timeseries.hpp @@ -145,8 +145,8 @@ namespace QuantLib { // The following typedef enables reverse iterators for // bidirectional_iterator_tag category. typedef std::conditional_t< - std::is_same::value || - std::is_base_of::value, + std::is_same_v || + std::is_base_of_v, std::bidirectional_iterator_tag, std::input_iterator_tag> enable_reverse; typedef typename diff --git a/ql/utilities/steppingiterator.hpp b/ql/utilities/steppingiterator.hpp index ae7b3e48f07..8bb658f35b0 100644 --- a/ql/utilities/steppingiterator.hpp +++ b/ql/utilities/steppingiterator.hpp @@ -61,8 +61,8 @@ namespace QuantLib { template step_iterator(const step_iterator& i, - std::enable_if_t::value>* = nullptr) + std::enable_if_t>* = nullptr) : base_(i.base_), step_(static_cast(i.step())) {} Size step() const { return static_cast(this->step_); } diff --git a/test-suite/digitaloption.cpp b/test-suite/digitaloption.cpp index 8eb5f334775..200993adb1d 100644 --- a/test-suite/digitaloption.cpp +++ b/test-suite/digitaloption.cpp @@ -22,6 +22,7 @@ #include "toplevelfixture.hpp" #include "utilities.hpp" +#include #include #include #include @@ -418,9 +419,9 @@ BOOST_AUTO_TEST_CASE(testCashAtExpiryOrNothingAmericanValues) { Handle(volTS))); ext::shared_ptr engine; if (value.knockin) - engine.reset(new AnalyticDigitalAmericanEngine(stochProcess)); + engine = ext::make_shared(stochProcess); else - engine.reset(new AnalyticDigitalAmericanKOEngine(stochProcess)); + engine = ext::make_shared(stochProcess); VanillaOption opt(payoff, amExercise); opt.setPricingEngine(engine); @@ -490,9 +491,9 @@ BOOST_AUTO_TEST_CASE(testAssetAtExpiryOrNothingAmericanValues) { Handle(volTS))); ext::shared_ptr engine; if (value.knockin) - engine.reset(new AnalyticDigitalAmericanEngine(stochProcess)); + engine = ext::make_shared(stochProcess); else - engine.reset(new AnalyticDigitalAmericanKOEngine(stochProcess)); + engine = ext::make_shared(stochProcess); VanillaOption opt(payoff, amExercise); opt.setPricingEngine(engine); diff --git a/test-suite/doublebinaryoption.cpp b/test-suite/doublebinaryoption.cpp index dff063fd5e6..1106657caf4 100644 --- a/test-suite/doublebinaryoption.cpp +++ b/test-suite/doublebinaryoption.cpp @@ -19,6 +19,7 @@ Copyright (C) 2015 Thema Consulting SA #include "toplevelfixture.hpp" #include "utilities.hpp" +#include #include #include #include @@ -194,9 +195,9 @@ BOOST_AUTO_TEST_CASE(testHaugValues) { Date exDate = today + timeToDays(value.t); ext::shared_ptr exercise; if (value.barrierType == DoubleBarrier::KIKO || value.barrierType == DoubleBarrier::KOKI) - exercise.reset(new AmericanExercise(today, exDate)); + exercise = ext::make_shared(today, exDate); else - exercise.reset(new EuropeanExercise(exDate)); + exercise = ext::make_shared(exDate); spot->setValue(value.s); qRate->setValue(value.q);