Skip to content

Commit bbbc495

Browse files
committed
Merge remote-tracking branch 'eltoder/feature/null-deleter' into ghpr_20230907
2 parents 6c97893 + 47c741f commit bbbc495

16 files changed

Lines changed: 34 additions & 82 deletions

QuantExt/qle/models/linkablecalibratedmodel.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,22 @@
1919
#include <ql/math/optimization/problem.hpp>
2020
#include <ql/math/optimization/projectedconstraint.hpp>
2121
#include <ql/math/optimization/projection.hpp>
22+
#include <ql/utilities/null_deleter.hpp>
2223
#include <qle/models/linkablecalibratedmodel.hpp>
2324

2425
using boost::shared_ptr;
2526
using std::vector;
2627

2728
namespace QuantExt {
2829

29-
namespace {
30-
void no_deletion(void*) {}
31-
} // namespace
32-
3330
LinkableCalibratedModel::LinkableCalibratedModel()
3431
: constraint_(new PrivateConstraint(arguments_)), endCriteria_(EndCriteria::None) {}
3532

3633
class LinkableCalibratedModel::CalibrationFunction : public CostFunction {
3734
public:
3835
CalibrationFunction(LinkableCalibratedModel* model, const vector<shared_ptr<CalibrationHelper> >& h,
3936
const vector<Real>& weights, const Projection& projection)
40-
: model_(model, no_deletion), instruments_(h), weights_(weights), projection_(projection) {}
37+
: model_(model, null_deleter()), instruments_(h), weights_(weights), projection_(projection) {}
4138

4239
virtual ~CalibrationFunction() {}
4340

QuantExt/qle/termstructures/averageoisratehelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
1717
*/
1818

19+
#include <ql/utilities/null_deleter.hpp>
1920
#include <qle/instruments/makeaverageois.hpp>
2021
#include <qle/termstructures/averageoisratehelper.hpp>
2122

2223
namespace QuantExt {
2324

24-
namespace {
25-
void no_deletion(YieldTermStructure*) {}
26-
} // namespace
27-
2825
AverageOISRateHelper::AverageOISRateHelper(const Handle<Quote>& fixedRate, const Period& spotLagTenor,
2926
const Period& swapTenor,
3027
// Fixed leg
@@ -95,7 +92,7 @@ Real AverageOISRateHelper::impliedQuote() const {
9592
void AverageOISRateHelper::setTermStructure(YieldTermStructure* t) {
9693

9794
bool observer = false;
98-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
95+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
9996
termStructureHandle_.linkTo(temp, observer);
10097

10198
if (discountHandle_.empty())

QuantExt/qle/termstructures/basistwoswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
#include <ql/cashflows/floatingratecoupon.hpp>
2020
#include <ql/cashflows/iborcoupon.hpp>
2121
#include <ql/instruments/makevanillaswap.hpp>
22+
#include <ql/utilities/null_deleter.hpp>
2223
#include <qle/termstructures/basistwoswaphelper.hpp>
2324

2425
namespace QuantExt {
2526

26-
namespace {
27-
void no_deletion(YieldTermStructure*) {}
28-
} // namespace
29-
3027
BasisTwoSwapHelper::BasisTwoSwapHelper(const Handle<Quote>& spread, const Period& swapTenor, const Calendar& calendar,
3128
// Long tenor swap
3229
Frequency longFixedFrequency, BusinessDayConvention longFixedConvention,
@@ -120,7 +117,7 @@ void BasisTwoSwapHelper::setTermStructure(YieldTermStructure* t) {
120117

121118
bool observer = false;
122119

123-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
120+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
124121
termStructureHandle_.linkTo(temp, observer);
125122

126123
if (discountHandle_.empty())

QuantExt/qle/termstructures/brlcdiratehelper.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
*/
1818

1919
#include <ql/pricingengines/swap/discountingswapengine.hpp>
20+
#include <ql/utilities/null_deleter.hpp>
2021
#include <qle/instruments/brlcdiswap.hpp>
2122
#include <qle/termstructures/brlcdiratehelper.hpp>
2223

2324
using namespace QuantLib;
2425

25-
namespace {
26-
void no_deletion(YieldTermStructure*) {}
27-
} // namespace
28-
2926
namespace QuantExt {
3027

3128
BRLCdiRateHelper::BRLCdiRateHelper(const Period& swapTenor, const Handle<Quote>& fixedRate,
@@ -80,7 +77,7 @@ void BRLCdiRateHelper::initializeDates() {
8077
void BRLCdiRateHelper::setTermStructure(YieldTermStructure* t) {
8178

8279
bool observer = false;
83-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
80+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
8481
termStructureHandle_.linkTo(temp, observer);
8582

8683
if (discountHandle_.empty())
@@ -138,7 +135,7 @@ DatedBRLCdiRateHelper::DatedBRLCdiRateHelper(const Date& startDate, const Date&
138135
void DatedBRLCdiRateHelper::setTermStructure(YieldTermStructure* t) {
139136

140137
bool observer = false;
141-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
138+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
142139
termStructureHandle_.linkTo(temp, observer);
143140

144141
if (discountHandle_.empty())

QuantExt/qle/termstructures/capfloorhelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@
2222
#include <ql/pricingengines/capfloor/bacheliercapfloorengine.hpp>
2323
#include <ql/pricingengines/capfloor/blackcapfloorengine.hpp>
2424
#include <ql/quotes/derivedquote.hpp>
25+
#include <ql/utilities/null_deleter.hpp>
2526
#include <qle/termstructures/capfloorhelper.hpp>
2627

2728
using namespace QuantLib;
2829
using std::ostream;
2930

30-
namespace {
31-
void no_deletion(OptionletVolatilityStructure*) {}
32-
} // namespace
33-
3431
namespace QuantExt {
3532

3633
// The argument to RelativeDateBootstrapHelper below is not simply the `quote`. Instead we create a DerivedQuote that,
@@ -132,7 +129,7 @@ void CapFloorHelper::setTermStructure(OptionletVolatilityStructure* ovts) {
132129
}
133130

134131
// Set this helper's optionlet volatility structure
135-
boost::shared_ptr<OptionletVolatilityStructure> temp(ovts, no_deletion);
132+
boost::shared_ptr<OptionletVolatilityStructure> temp(ovts, null_deleter());
136133
ovtsHandle_.linkTo(temp, false);
137134

138135
// Set the term structure pointer member variable in the base class

QuantExt/qle/termstructures/crossccybasismtmresetswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
1717
*/
1818
#include <ql/cashflows/iborcoupon.hpp>
19+
#include <ql/utilities/null_deleter.hpp>
1920
#include <qle/pricingengines/crossccyswapengine.hpp>
2021

2122
#include <qle/termstructures/crossccybasismtmresetswaphelper.hpp>
@@ -24,10 +25,6 @@
2425

2526
namespace QuantExt {
2627

27-
namespace {
28-
void no_deletion(YieldTermStructure*) {}
29-
} // namespace
30-
3128
CrossCcyBasisMtMResetSwapHelper::CrossCcyBasisMtMResetSwapHelper(
3229
const Handle<Quote>& spreadQuote, const Handle<Quote>& spotFX, Natural settlementDays,
3330
const Calendar& settlementCalendar, const Period& swapTenor, BusinessDayConvention rollConvention,
@@ -205,7 +202,7 @@ void CrossCcyBasisMtMResetSwapHelper::initializeDates() {
205202
void CrossCcyBasisMtMResetSwapHelper::setTermStructure(YieldTermStructure* t) {
206203

207204
bool observer = false;
208-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
205+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
209206

210207
termStructureHandle_.linkTo(temp, observer);
211208

QuantExt/qle/termstructures/crossccybasisswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
1717
*/
1818
#include <ql/cashflows/iborcoupon.hpp>
19+
#include <ql/utilities/null_deleter.hpp>
1920
#include <qle/pricingengines/crossccyswapengine.hpp>
2021

2122
#include <qle/termstructures/crossccybasisswaphelper.hpp>
@@ -24,10 +25,6 @@
2425

2526
namespace QuantExt {
2627

27-
namespace {
28-
void no_deletion(YieldTermStructure*) {}
29-
} // namespace
30-
3128
CrossCcyBasisSwapHelper::CrossCcyBasisSwapHelper(
3229
const Handle<Quote>& spreadQuote, const Handle<Quote>& spotFX, Natural settlementDays,
3330
const Calendar& settlementCalendar, const Period& swapTenor, BusinessDayConvention rollConvention,
@@ -200,7 +197,7 @@ void CrossCcyBasisSwapHelper::initializeDates() {
200197
void CrossCcyBasisSwapHelper::setTermStructure(YieldTermStructure* t) {
201198

202199
bool observer = false;
203-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
200+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
204201

205202
termStructureHandle_.linkTo(temp, observer);
206203

QuantExt/qle/termstructures/crossccyfixfloatmtmresetswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
*/
1818
#include <boost/make_shared.hpp>
1919
#include <ql/cashflows/iborcoupon.hpp>
20+
#include <ql/utilities/null_deleter.hpp>
2021
#include <qle/pricingengines/crossccyswapengine.hpp>
2122
#include <qle/termstructures/crossccyfixfloatmtmresetswaphelper.hpp>
2223

2324
namespace QuantExt {
2425

25-
namespace {
26-
void no_deletion(YieldTermStructure*) {}
27-
} // namespace
28-
2926
CrossCcyFixFloatMtMResetSwapHelper::CrossCcyFixFloatMtMResetSwapHelper(
3027
const Handle<Quote>& rate, const Handle<Quote>& spotFx, Natural settlementDays, const Calendar& paymentCalendar,
3128
BusinessDayConvention paymentConvention, const Period& tenor, const Currency& fixedCurrency,
@@ -115,7 +112,7 @@ void CrossCcyFixFloatMtMResetSwapHelper::initializeDates() {
115112
}
116113

117114
void CrossCcyFixFloatMtMResetSwapHelper::setTermStructure(YieldTermStructure* t) {
118-
boost::shared_ptr<YieldTermStructure> temp(t, no_deletion);
115+
boost::shared_ptr<YieldTermStructure> temp(t, null_deleter());
119116
termStructureHandle_.linkTo(temp, false);
120117
RelativeDateRateHelper::setTermStructure(t);
121118
}

QuantExt/qle/termstructures/crossccyfixfloatswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <boost/make_shared.hpp>
2020
#include <ql/cashflows/fixedratecoupon.hpp>
2121
#include <ql/math/comparison.hpp>
22+
#include <ql/utilities/null_deleter.hpp>
2223
#include <qle/pricingengines/crossccyswapengine.hpp>
2324
#include <qle/termstructures/crossccyfixfloatswaphelper.hpp>
2425

@@ -29,10 +30,6 @@ using QuantLib::YieldTermStructure;
2930

3031
namespace QuantExt {
3132

32-
namespace {
33-
void no_deletion(YieldTermStructure*) {}
34-
} // namespace
35-
3633
CrossCcyFixFloatSwapHelper::CrossCcyFixFloatSwapHelper(
3734
const Handle<Quote>& rate, const Handle<Quote>& spotFx, Natural settlementDays, const Calendar& paymentCalendar,
3835
BusinessDayConvention paymentConvention, const Period& tenor, const Currency& fixedCurrency,
@@ -76,7 +73,7 @@ Real CrossCcyFixFloatSwapHelper::impliedQuote() const {
7673
}
7774

7875
void CrossCcyFixFloatSwapHelper::setTermStructure(YieldTermStructure* yts) {
79-
boost::shared_ptr<YieldTermStructure> temp(yts, no_deletion);
76+
boost::shared_ptr<YieldTermStructure> temp(yts, null_deleter());
8077
termStructureHandle_.linkTo(temp, false);
8178
RelativeDateRateHelper::setTermStructure(yts);
8279
}

QuantExt/qle/termstructures/doubleoibasisswaphelper.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <ql/pricingengines/swap/discountingswapengine.hpp>
20+
#include <ql/utilities/null_deleter.hpp>
2021
#include <qle/termstructures/doubleoibasisswaphelper.hpp>
2122

2223
using boost::shared_ptr;
@@ -25,10 +26,6 @@ using namespace QuantLib;
2526

2627
namespace QuantExt {
2728

28-
namespace {
29-
void no_deletion(YieldTermStructure*) {}
30-
} // namespace
31-
3229
DoubleOIBSHelper::DoubleOIBSHelper(Natural settlementDays,
3330
const Period& swapTenor, const Handle<Quote>& spread, const boost::shared_ptr<OvernightIndex>& payIndex,
3431
const boost::shared_ptr<OvernightIndex>& recIndex, const Handle<YieldTermStructure>& discount, const bool spreadOnPayLeg,
@@ -134,7 +131,7 @@ void DoubleOIBSHelper::initializeDates() {
134131
void DoubleOIBSHelper::setTermStructure(YieldTermStructure* t) {
135132
// do not set the relinkable handle as an observer -
136133
// force recalculation when needed
137-
termStructureHandle_.linkTo(shared_ptr<YieldTermStructure>(t, no_deletion), false);
134+
termStructureHandle_.linkTo(shared_ptr<YieldTermStructure>(t, null_deleter()), false);
138135
RelativeDateRateHelper::setTermStructure(t);
139136
}
140137

0 commit comments

Comments
 (0)