From 33c47e18744362e943cda99ac8223c4954a3de02 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 14:54:31 +0000 Subject: [PATCH] =?UTF-8?q?Migrate=20ext::optional=20=E2=86=92=20std::opti?= =?UTF-8?q?onal=20and=20remove=20Boost=20optional=20shim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace all ext::optional with std::optional and ext::nullopt with std::nullopt across 79 source files. Replace #include with #include . Tombstone ql/optional.hpp to a thin deprecated #include (matching the pattern of functional.hpp and tuple.hpp). Remove the QL_USE_STD_OPTIONAL build flag from CMakeLists.txt, CMakePresets.json, configure.ac, ql/userconfig.hpp, ql/config.hpp.cfg, .ci/userconfig*.alt.hpp, and Docs/pages/config.docs. Update AGENTS.md and Docs/pages/modernization.docs to reflect the completed migration. This is the highest-priority modernization because ql/optional.hpp carried a #error on Boost >= 1.91 due to silent pricing-correctness breakage, and optional appeared on public price-affecting APIs (Settings::includeTodaysCashFlows_, Event::hasOccurred). Local verification: 100% build, 100% tests passed (0 failed). Co-Authored-By: Toby Drinkall --- .ci/userconfig2019.alt.hpp | 4 - .ci/userconfig2022.alt.hpp | 4 - .ci/userconfig2026.alt.hpp | 4 - AGENTS.md | 56 +++++------- CMakeLists.txt | 2 - CMakePresets.json | 2 - Docs/pages/config.docs | 8 -- Docs/pages/modernization.docs | 90 ++++++++----------- configure.ac | 20 ----- ql/cashflow.cpp | 4 +- ql/cashflow.hpp | 4 +- ql/cashflows/cashflows.cpp | 88 +++++++++--------- ql/cashflows/cashflows.hpp | 86 +++++++++--------- ql/cashflows/couponpricer.cpp | 4 +- ql/cashflows/couponpricer.hpp | 6 +- ql/cashflows/iborcoupon.cpp | 4 +- ql/cashflows/iborcoupon.hpp | 6 +- ql/cashflows/overnightindexedcoupon.cpp | 2 +- ql/cashflows/overnightindexedcoupon.hpp | 4 +- ql/config.hpp.cfg | 1 - ql/event.cpp | 4 +- ql/event.hpp | 4 +- .../catbonds/montecarlocatbondengine.cpp | 4 +- .../catbonds/montecarlocatbondengine.hpp | 6 +- .../coupons/lognormalcmsspreadpricer.cpp | 4 +- .../coupons/lognormalcmsspreadpricer.hpp | 4 +- ql/experimental/credit/syntheticcdo.cpp | 4 +- ql/experimental/credit/syntheticcdo.hpp | 4 +- .../crosscurrencyratehelpers.cpp | 22 ++--- .../crosscurrencyratehelpers.hpp | 18 ++-- ql/instruments/bond.cpp | 2 +- ql/instruments/callabilityschedule.hpp | 4 +- ql/instruments/creditdefaultswap.cpp | 10 +-- ql/instruments/creditdefaultswap.hpp | 8 +- ql/instruments/fixedvsfloatingswap.cpp | 2 +- ql/instruments/fixedvsfloatingswap.hpp | 4 +- ql/instruments/floatfloatswap.cpp | 14 +-- ql/instruments/floatfloatswap.hpp | 14 +-- ql/instruments/makecds.hpp | 8 +- ql/instruments/makeois.hpp | 2 +- ql/instruments/makeswaption.cpp | 4 +- ql/instruments/makeswaption.hpp | 6 +- ql/instruments/makevanillaswap.cpp | 4 +- ql/instruments/makevanillaswap.hpp | 8 +- ql/instruments/multipleresetsswap.cpp | 2 +- ql/instruments/multipleresetsswap.hpp | 2 +- ql/instruments/nonstandardswap.cpp | 6 +- ql/instruments/nonstandardswap.hpp | 6 +- ql/instruments/overnightindexedswap.cpp | 2 +- ql/instruments/vanillaswap.cpp | 4 +- ql/instruments/vanillaswap.hpp | 6 +- ql/optional.hpp | 28 +----- .../bond/discountingbondengine.cpp | 4 +- .../bond/discountingbondengine.hpp | 6 +- .../capfloor/analyticcapfloorengine.cpp | 4 +- .../credit/integralcdsengine.cpp | 4 +- .../credit/integralcdsengine.hpp | 6 +- ql/pricingengines/credit/isdacdsengine.cpp | 4 +- ql/pricingengines/credit/isdacdsengine.hpp | 6 +- .../credit/midpointcdsengine.cpp | 4 +- .../credit/midpointcdsengine.hpp | 6 +- .../discountingperpetualfuturesengine.hpp | 2 +- .../mclongstaffschwartzengine.hpp | 10 +-- ...ngconstnotionalcrosscurrencyswapengine.cpp | 2 +- ...ngconstnotionalcrosscurrencyswapengine.hpp | 6 +- .../swap/discountingswapengine.cpp | 4 +- .../swap/discountingswapengine.hpp | 6 +- .../vanilla/mcamericanengine.hpp | 10 +-- ql/quantlib.hpp | 2 +- ql/settings.hpp | 14 +-- .../equityfx/blackvolsurfacedelta.cpp | 4 +- .../equityfx/blackvolsurfacedelta.hpp | 4 +- .../optionlet/optionletstripper.cpp | 4 +- .../optionlet/optionletstripper.hpp | 6 +- .../optionlet/optionletstripper1.cpp | 2 +- .../optionlet/optionletstripper1.hpp | 2 +- ql/termstructures/yield/oisratehelper.cpp | 8 +- ql/termstructures/yield/oisratehelper.hpp | 14 +-- ql/termstructures/yield/ratehelpers.cpp | 12 +-- ql/termstructures/yield/ratehelpers.hpp | 20 ++--- .../yield/ultimateforwardtermstructure.hpp | 8 +- ql/time/schedule.cpp | 10 +-- ql/time/schedule.hpp | 24 ++--- ql/userconfig.hpp | 9 -- test-suite/blackvolsurfacedelta.cpp | 14 +-- test-suite/cashflows.cpp | 10 +-- test-suite/creditdefaultswap.cpp | 8 +- test-suite/crosscurrencyratehelpers.cpp | 24 ++--- test-suite/defaultprobabilitycurves.cpp | 2 +- test-suite/overnightindexedswap.cpp | 10 +-- test-suite/period.cpp | 2 +- test-suite/quantlibglobalfixture.cpp | 2 +- test-suite/ultimateforwardtermstructure.cpp | 2 +- 93 files changed, 404 insertions(+), 516 deletions(-) diff --git a/.ci/userconfig2019.alt.hpp b/.ci/userconfig2019.alt.hpp index 15ab7ddc97d..75ba606cfb9 100644 --- a/.ci/userconfig2019.alt.hpp +++ b/.ci/userconfig2019.alt.hpp @@ -101,10 +101,6 @@ //# define QL_USE_STD_ANY #endif -/* Define this to use std::optional instead of boost::optional. */ -#ifndef QL_USE_STD_OPTIONAL -//# define QL_USE_STD_OPTIONAL -#endif /* Define this to use standard smart pointers instead of Boost ones. Note that std::shared_ptr does not check access and can diff --git a/.ci/userconfig2022.alt.hpp b/.ci/userconfig2022.alt.hpp index e714c4fbf01..75ba606cfb9 100644 --- a/.ci/userconfig2022.alt.hpp +++ b/.ci/userconfig2022.alt.hpp @@ -101,10 +101,6 @@ //# define QL_USE_STD_ANY #endif -/* Define this to use std::optional instead of boost::optional. */ -#ifndef QL_USE_STD_OPTIONAL -# define QL_USE_STD_OPTIONAL -#endif /* Define this to use standard smart pointers instead of Boost ones. Note that std::shared_ptr does not check access and can diff --git a/.ci/userconfig2026.alt.hpp b/.ci/userconfig2026.alt.hpp index e714c4fbf01..75ba606cfb9 100644 --- a/.ci/userconfig2026.alt.hpp +++ b/.ci/userconfig2026.alt.hpp @@ -101,10 +101,6 @@ //# define QL_USE_STD_ANY #endif -/* Define this to use std::optional instead of boost::optional. */ -#ifndef QL_USE_STD_OPTIONAL -# define QL_USE_STD_OPTIONAL -#endif /* Define this to use standard smart pointers instead of Boost ones. Note that std::shared_ptr does not check access and can diff --git a/AGENTS.md b/AGENTS.md index f8a3920c82a..a20f0160d35 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,10 +1,7 @@ # Agent guide — modernization work in this repository This file orients AI agents (and new contributors) working in this repository. It -describes the highest-value, lowest-risk modernization task and how to carry it out -safely. If you are asked an open-ended question like *"what should we modernize?"*, -*"what legacy dependencies are risky?"*, or *"what's the safest high-impact change to -make here?"*, treat the work below as the canonical answer and starting point. +describes the modernization status and the next high-value task. ## Context @@ -14,47 +11,36 @@ reasons it still reaches Boost through a set of **compatibility shims** in `ql/` into `namespace QuantLib::ext` behind `QL_USE_STD_*` build flags. These shims are explicitly deprecated; the project intends to move to standard C++17 facilities. -## The canonical modernization task: drop the Boost `optional` shim first +## Completed: `ext::optional` → `std::optional` -When prioritising which shim to remove, rank by **correctness risk** (the chance a -dependency bump silently changes a *pricing result* without failing the build), not -just by blast radius. On that axis, **`ext::optional` → `std::optional` is the one to -do first**: +The `optional` shim migration is **complete**. All `ext::optional` / `ext::nullopt` +usages across ~79 files have been replaced with `std::optional` / `std::nullopt`. +The `QL_USE_STD_OPTIONAL` build flag has been removed from all config files, and +`ql/optional.hpp` is now a tombstoned deprecated header (like `functional.hpp` and +`tuple.hpp`). -- `ql/optional.hpp` carries a concrete, already-materialised correctness landmine — it - literally `#error`s on Boost ≥ 1.91 because *"Boost 1.91 introduced changes in - boost::optional that silently changed the behavior of our code and would cause it to - work incorrectly."* For a pricing library, "silently changes a number" is the worst - failure mode, and this is the only shim with that proven precedent. -- `optional` appears on **public, price-affecting APIs** (`Settings::includeTodaysCashFlows_` - controls NPV inclusion; `Event::hasOccurred(Date, optional)` controls accrual), - so the change is meaningful, not cosmetic. -- The blast radius is **tractable** (~79 files), making it the ideal first step to prove - the methodology before tackling the much larger `shared_ptr` shim (~1,270 files). +This was the highest-priority migration because: +- `ql/optional.hpp` carried a `#error` on Boost ≥ 1.91 due to silent + pricing-correctness breakage. +- `optional` appeared on **public, price-affecting APIs** + (`Settings::includeTodaysCashFlows_`, `Event::hasOccurred`). -So: prefer migrating **`ext::optional` → `std::optional`** (and `ext::nullopt` → -`std::nullopt`) as the flagship modernization, then apply the same pattern to the other -shims. +## Next modernization task: drop the Boost `any` shim, then `shared_ptr` -## How to execute it (and how to prove nothing changed) +The next shim to remove is `ext::any` → `std::any`, followed by the much larger +`shared_ptr` shim (~1,270 files). Apply the same methodology proven with `optional`: -1. **Map the blast radius first** and present it (counts, affected layers, safe order). - `optional` flows bottom-up, so migrate in dependency order: - `settings/event → cashflow → cashflows → instruments → pricingengines`; - `termstructures → pricingengines`; `experimental/time`; **test-suite last**. - Headers before their `.cpp`. -2. **Migrate mechanically:** `ext::optional` → `std::optional`, - `ext::nullopt` → `std::nullopt`, `#include ` → `#include ` - (every file naming `std::optional` must include `` directly). -3. **Remove the now-dead flag** `QL_USE_STD_OPTIONAL` from `CMakeLists.txt`, +1. **Map the blast radius** and present it (counts, affected layers, safe order). +2. **Migrate mechanically** in dependency order (bottom-up). +3. **Remove the now-dead `QL_USE_STD_*` flag** from `CMakeLists.txt`, `CMakePresets.json`, `configure.ac`, `ql/userconfig.hpp`, `ql/config.hpp.cfg`, - `.ci/userconfig*.alt.hpp`, and `Docs/pages/config.docs`; reduce `ql/optional.hpp` to a - thin deprecated `#include `. + `.ci/userconfig*.alt.hpp`, and `Docs/pages/config.docs`; reduce the shim header + to a thin deprecated `#include`. 4. **Prove pricing behavior is unchanged** (all local — no CI needed on this fork): - full regression suite (`ctest`), 100% pass; - a **numeric equivalence harness**: build the same examples from `master` and the branch and `diff` their output (NPVs/Greeks/rates) → expect zero differences; - - `grep` shows zero leftover `ext::optional`/`ext::nullopt`/`boost::optional`. + - `grep` shows zero leftover shim usages. 5. **Open a PR** that includes the dependency map and the verification results. See `Docs/pages/modernization.docs` for the full roadmap and rationale. diff --git a/CMakeLists.txt b/CMakeLists.txt index f346b7e665c..e4f47a6520d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,6 @@ option(QL_USE_CLANG_TIDY "Use clang-tidy when building" OFF) option(QL_USE_INDEXED_COUPON "Use indexed coupons instead of par coupons" OFF) option(QL_USE_STD_ANY "Use std::any instead of boost::any" ON) option(QL_USE_STD_CLASSES "Enable all QL_USE_STD_ options" OFF) -option(QL_USE_STD_OPTIONAL "Use std::optional instead of boost::optional" ON) option(QL_USE_STD_SHARED_PTR "Use standard smart pointers instead of Boost ones" OFF) set(QL_EXTERNAL_SUBDIRECTORIES "" CACHE STRING "Optional list of external source directories to be added to the build (semicolon-separated)") # set -lpapi here @@ -87,7 +86,6 @@ endif() # Convenience option to activate all STD options if (QL_USE_STD_CLASSES) set(QL_USE_STD_ANY ON) - set(QL_USE_STD_OPTIONAL ON) set(QL_USE_STD_SHARED_PTR ON) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 901270f62a9..59d28bfc7bd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -303,7 +303,6 @@ "QL_USE_INDEXED_COUPON": "ON", "QL_USE_STD_SHARED_PTR": "ON", "QL_USE_STD_ANY": "OFF", - "QL_USE_STD_OPTIONAL": "OFF", "QL_COMPILE_WARNING_AS_ERROR": "ON" } }, @@ -323,7 +322,6 @@ "QL_USE_INDEXED_COUPON": "ON", "QL_USE_STD_SHARED_PTR": "ON", "QL_USE_STD_ANY": "OFF", - "QL_USE_STD_OPTIONAL": "OFF", "QL_COMPILE_WARNING_AS_ERROR": "ON", "CMAKE_CXX_COMPILER_LAUNCHER": "sccache" } diff --git a/Docs/pages/config.docs b/Docs/pages/config.docs index c5b4eb82f58..cc2518f9346 100644 --- a/Docs/pages/config.docs +++ b/Docs/pages/config.docs @@ -125,14 +125,6 @@ functions will be used instead of `boost::any`. If undefined, the Boost facilities will be used. - \code - #define QL_USE_STD_OPTIONAL - \endcode - If defined (the default), `std::optional` and related classes and - functions will be used instead of `boost::optional`. If undefined, - the Boost facilities will be used; however, be aware that Boost - 1.91 introduced changes in boost::optional that silently changed - the behavior of our code and would cause it to work incorrectly. \code #define QL_USE_STD_SHARED_PTR diff --git a/Docs/pages/modernization.docs b/Docs/pages/modernization.docs index 32679d48e06..f9f08307cd5 100644 --- a/Docs/pages/modernization.docs +++ b/Docs/pages/modernization.docs @@ -25,59 +25,40 @@ \c QL_USE_STD_* flag. These shims are deprecated; the goal is to move to standard C++17 facilities. - This page records the recommended order of work and, in particular, the - flagship first migration. - - \section modernization_priority What to do first, and why - - When deciding which shim to remove first, rank by correctness risk -- - the chance that a dependency upgrade silently changes a pricing - result without failing the build -- not merely by how many files are - touched. In a pricing library a silent change of a number is the most - dangerous failure mode. - - On that measure, the \c optional shim is the clear first target: - - - \c ql/optional.hpp contains an explicit guard that \#errors on - Boost ≥ 1.91, because Boost 1.91 introduced changes in - \c boost::optional that silently changed the behavior of the code - and would cause it to work incorrectly. It is the only shim with a proven - silent-correctness precedent. - - \c optional appears on public, price-affecting APIs: the - \c includeTodaysCashFlows_ setting (NPV inclusion of today's flows) and - \c Event::hasOccurred (whether a cash flow has already occurred, which - drives accrual). A wrong empty-state semantics here changes valuations. - - Its blast radius is tractable (about 79 files), which makes it the ideal - first step to prove the methodology before tackling the much larger - \c shared_ptr shim (around 1,270 files). - - Recommended order: optional first, then \c any, then \c functional / - \c tuple, and finally the large \c shared_ptr migration. - - \section modernization_optional The optional migration in detail - - Replace \c ext::optional with \c std::optional and \c ext::nullopt with - \c std::nullopt, and replace \#include <ql/optional.hpp> with - \#include <optional> (every translation unit that names - \c std::optional must include \c <optional> directly). - - \c optional flows from low-level headers upward, so migrate bottom-up to keep - the build green at every step: - - \code - settings.hpp / event.hpp -> cashflow.hpp -> cashflows/* -> instruments/* - -> pricingengines/* - termstructures/* -> pricingengines/* - experimental/*, time/* - test-suite/* (migrate last -- it consumes the whole library) - \endcode - - Headers migrate before their corresponding \c .cpp files. Once the usages are - migrated, remove the now-dead \c QL_USE_STD_OPTIONAL option from - \c CMakeLists.txt, \c CMakePresets.json, \c configure.ac, - \c ql/userconfig.hpp, \c ql/config.hpp.cfg, the \c .ci/userconfig*.alt.hpp - files and \c Docs/pages/config.docs, and reduce \c ql/optional.hpp to a thin - deprecated \#include <optional> for backward compatibility. + This page records the recommended order of work and the status of each + migration. + + \section modernization_completed Completed migrations + + \subsection modernization_optional optional (completed) + + The \c ext::optional / \c ext::nullopt shim has been fully migrated to + \c std::optional / \c std::nullopt. This was the highest-priority migration + because \c ql/optional.hpp contained an explicit \#error guard on + Boost ≥ 1.91 due to silent pricing-correctness breakage, and the type + appeared on public, price-affecting APIs (\c Settings::includeTodaysCashFlows_, + \c Event::hasOccurred). + + What was done: + - All \c ext::optional usages (79 files) replaced with \c std::optional. + - All \c ext::nullopt usages replaced with \c std::nullopt. + - All \#include <ql/optional.hpp> replaced with + \#include <optional>. + - \c ql/optional.hpp reduced to a thin deprecated + \#include <optional> tombstone. + - The \c QL_USE_STD_OPTIONAL build flag removed from \c CMakeLists.txt, + \c CMakePresets.json, \c configure.ac, \c ql/userconfig.hpp, + \c ql/config.hpp.cfg, the \c .ci/userconfig*.alt.hpp files and + \c Docs/pages/config.docs. + - Full regression suite passes with unchanged pricing results. + + The \c functional and \c tuple shims were previously migrated and their + headers are already tombstoned. + + \section modernization_next Next migrations + + Recommended order for remaining shims: \c any, then \c shared_ptr (the + largest at around 1,270 files). \section modernization_proof Proving pricing behavior is unchanged @@ -89,8 +70,7 @@ \c master and from the migration branch, run each, and \c diff their output (NPVs, Greeks, rates) -- expect zero differences across instruments such as EquityOption, Bonds, BermudanSwaption, FRA, MulticurveBootstrapping and CDS; - - confirm with \c grep that no \c ext::optional, \c ext::nullopt or - \c boost::optional usages remain. + - confirm with \c grep that no leftover shim usages remain. Together these constitute the change-control evidence such a modernization requires: the blast radius is mapped and the behavior is proven unchanged. diff --git a/configure.ac b/configure.ac index c9d3701c16c..aa596dc35a4 100644 --- a/configure.ac +++ b/configure.ac @@ -287,24 +287,6 @@ if test "$ql_use_std_any" = "yes" ; then fi AC_MSG_RESULT([$ql_use_std_any]) -AC_MSG_CHECKING([whether to enable std::optional instead of boost::optional]) -AC_ARG_ENABLE([std-optional], - AS_HELP_STRING([--enable-std-optional], - [If enabled (the default), std::optional and - related classes and functions will be used - instead of boost::optional. If disabled, - the Boost facilities will be used; however, - be aware that Boost 1.91 introduced changes - in boost::optional that silently changed - the behavior of our code and would cause it - to work incorrectly.]), - [ql_use_std_optional=$enableval], - [ql_use_std_optional=yes]) -if test "$ql_use_std_optional" = "yes" ; then - AC_DEFINE([QL_USE_STD_OPTIONAL],[1], - [Define this if you want to use std::optional.]) -fi -AC_MSG_RESULT([$ql_use_std_optional]) AC_MSG_CHECKING([whether to enable standard smart pointers]) AC_ARG_ENABLE([std-pointers], @@ -337,8 +319,6 @@ AC_ARG_ENABLE([std-classes], if test "$ql_use_std_classes" = "yes" ; then AC_DEFINE([QL_USE_STD_ANY],[1], [Define this if you want to use std::any.]) - AC_DEFINE([QL_USE_STD_OPTIONAL],[1], - [Define this if you want to use std::optional.]) AC_DEFINE([QL_USE_STD_SHARED_PTR],[1], [Define this if you want to use standard smart pointers.]) fi diff --git a/ql/cashflow.cpp b/ql/cashflow.cpp index 80c9c767034..2da64b349dd 100644 --- a/ql/cashflow.cpp +++ b/ql/cashflow.cpp @@ -25,7 +25,7 @@ namespace QuantLib { bool CashFlow::hasOccurred(const Date& refDate, - ext::optional includeRefDate) const { + std::optional includeRefDate) const { // easy and quick handling of most cases if (refDate != Date()) { @@ -40,7 +40,7 @@ namespace QuantLib { refDate == Settings::instance().evaluationDate()) { // today's date; we override the bool with the one // specified in the settings (if any) - ext::optional includeToday = + std::optional includeToday = Settings::instance().includeTodaysCashFlows(); if (includeToday.has_value()) includeRefDate = includeToday; diff --git a/ql/cashflow.hpp b/ql/cashflow.hpp index 955bd0ad865..82d115190ec 100644 --- a/ql/cashflow.hpp +++ b/ql/cashflow.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ namespace QuantLib { Settings::includeTodaysCashflows in account */ bool hasOccurred(const Date& refDate = Date(), - ext::optional includeRefDate = ext::nullopt) const override; + std::optional includeRefDate = std::nullopt) const override; //@} //! \name LazyObject interface //@{ diff --git a/ql/cashflows/cashflows.cpp b/ql/cashflows/cashflows.cpp index 3e4da21601c..6686a8cbd0f 100644 --- a/ql/cashflows/cashflows.cpp +++ b/ql/cashflows/cashflows.cpp @@ -64,7 +64,7 @@ namespace QuantLib { } bool CashFlows::isExpired(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (leg.empty()) @@ -82,7 +82,7 @@ namespace QuantLib { Leg::const_reverse_iterator CashFlows::previousCashFlow(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (leg.empty()) return leg.rend(); @@ -100,7 +100,7 @@ namespace QuantLib { Leg::const_iterator CashFlows::nextCashFlow(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (leg.empty()) return leg.end(); @@ -117,7 +117,7 @@ namespace QuantLib { } Date CashFlows::previousCashFlowDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_reverse_iterator cf; cf = previousCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -129,7 +129,7 @@ namespace QuantLib { } Date CashFlows::nextCashFlowDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_iterator cf; cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -141,7 +141,7 @@ namespace QuantLib { } Real CashFlows::previousCashFlowAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_reverse_iterator cf; cf = previousCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -157,7 +157,7 @@ namespace QuantLib { } Real CashFlows::nextCashFlowAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_iterator cf; cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -212,7 +212,7 @@ namespace QuantLib { } // anonymous namespace ends here Rate CashFlows::previousCouponRate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_reverse_iterator cf; cf = previousCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -221,7 +221,7 @@ namespace QuantLib { } Rate CashFlows::nextCouponRate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { Leg::const_iterator cf; cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); @@ -229,7 +229,7 @@ namespace QuantLib { } Real CashFlows::nominal(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) return 0.0; @@ -244,7 +244,7 @@ namespace QuantLib { } Date CashFlows::accrualStartDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) @@ -260,7 +260,7 @@ namespace QuantLib { } Date CashFlows::accrualEndDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) @@ -276,7 +276,7 @@ namespace QuantLib { } Date CashFlows::referencePeriodStart(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) @@ -292,7 +292,7 @@ namespace QuantLib { } Date CashFlows::referencePeriodEnd(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) @@ -308,7 +308,7 @@ namespace QuantLib { } Time CashFlows::accrualPeriod(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) return 0; @@ -323,7 +323,7 @@ namespace QuantLib { } Date::serial_type CashFlows::accrualDays(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { auto cf = nextCashFlow(leg, includeSettlementDateFlows, settlementDate); if (cf==leg.end()) return 0; @@ -338,7 +338,7 @@ namespace QuantLib { } Time CashFlows::accruedPeriod(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (settlementDate == Date()) settlementDate = Settings::instance().evaluationDate(); @@ -356,7 +356,7 @@ namespace QuantLib { } Date::serial_type CashFlows::accruedDays(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (settlementDate == Date()) settlementDate = Settings::instance().evaluationDate(); @@ -374,7 +374,7 @@ namespace QuantLib { } Real CashFlows::accruedAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate) { if (settlementDate == Date()) settlementDate = Settings::instance().evaluationDate(); @@ -423,7 +423,7 @@ namespace QuantLib { Real CashFlows::npv(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -448,7 +448,7 @@ namespace QuantLib { Real CashFlows::bps(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -471,7 +471,7 @@ namespace QuantLib { std::pair CashFlows::npvbps(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { Real npv = 0.0; @@ -508,7 +508,7 @@ namespace QuantLib { Rate CashFlows::atmRate(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate, Real targetNpv) { @@ -601,7 +601,7 @@ namespace QuantLib { Real simpleDuration(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -641,7 +641,7 @@ namespace QuantLib { Real modifiedDuration(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -708,7 +708,7 @@ namespace QuantLib { Real macaulayDuration(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -735,7 +735,7 @@ namespace QuantLib { DayCounter dayCounter, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) : leg_(leg), npv_(npv), dayCounter_(std::move(dayCounter)), compounding_(comp), @@ -812,7 +812,7 @@ namespace QuantLib { Real CashFlows::npv(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -859,7 +859,7 @@ namespace QuantLib { const DayCounter& dc, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return npv(leg, InterestRate(yield, dc, comp, freq), @@ -869,7 +869,7 @@ namespace QuantLib { Real CashFlows::bps(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -894,7 +894,7 @@ namespace QuantLib { const DayCounter& dc, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return bps(leg, InterestRate(yield, dc, comp, freq), @@ -907,7 +907,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate, Real accuracy, @@ -926,7 +926,7 @@ namespace QuantLib { Time CashFlows::duration(const Leg& leg, const InterestRate& rate, Duration::Type type, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -963,7 +963,7 @@ namespace QuantLib { Compounding comp, Frequency freq, Duration::Type type, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return duration(leg, InterestRate(yield, dc, comp, freq), @@ -974,7 +974,7 @@ namespace QuantLib { Real CashFlows::convexity(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -1048,7 +1048,7 @@ namespace QuantLib { const DayCounter& dc, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return convexity(leg, InterestRate(yield, dc, comp, freq), @@ -1058,7 +1058,7 @@ namespace QuantLib { Real CashFlows::basisPointValue(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -1095,7 +1095,7 @@ namespace QuantLib { const DayCounter& dc, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return basisPointValue(leg, InterestRate(yield, dc, comp, freq), @@ -1105,7 +1105,7 @@ namespace QuantLib { Real CashFlows::yieldValueBasisPoint(const Leg& leg, const InterestRate& y, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { if (leg.empty()) @@ -1134,7 +1134,7 @@ namespace QuantLib { const DayCounter& dc, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return yieldValueBasisPoint(leg, InterestRate(yield, dc, comp, freq), @@ -1148,7 +1148,7 @@ namespace QuantLib { Spread zSpread, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { @@ -1180,7 +1180,7 @@ namespace QuantLib { const DayCounter&, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) { return CashFlows::npv(leg, discountCurve, zSpread, comp, freq, @@ -1192,7 +1192,7 @@ namespace QuantLib { const ext::shared_ptr& discount, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate, Real accuracy, @@ -1230,7 +1230,7 @@ namespace QuantLib { const DayCounter&, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate, Real accuracy, diff --git a/ql/cashflows/cashflows.hpp b/ql/cashflows/cashflows.hpp index 43b661f9cb7..5a094004c1e 100644 --- a/ql/cashflows/cashflows.hpp +++ b/ql/cashflows/cashflows.hpp @@ -47,7 +47,7 @@ namespace QuantLib { DayCounter dayCounter, Compounding comp, Frequency freq, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate); @@ -61,7 +61,7 @@ namespace QuantLib { DayCounter dayCounter_; Compounding compounding_; Frequency frequency_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; Date settlementDate_, npvDate_; }; public: @@ -77,7 +77,7 @@ namespace QuantLib { static Date startDate(const Leg& leg); static Date maturityDate(const Leg& leg); static bool isExpired(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); //@} @@ -86,28 +86,28 @@ namespace QuantLib { //! the last cashflow paying before or at the given date static Leg::const_reverse_iterator previousCashFlow(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); //! the first cashflow paying after the given date static Leg::const_iterator nextCashFlow(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date previousCashFlowDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date nextCashFlowDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Real previousCashFlowAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Real nextCashFlowAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); //@} @@ -115,52 +115,52 @@ namespace QuantLib { //@{ static Rate previousCouponRate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Rate nextCouponRate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Real nominal(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date accrualStartDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date accrualEndDate(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date referencePeriodStart(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date referencePeriodEnd(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Time accrualPeriod(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date::serial_type accrualDays(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Time accruedPeriod(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Date::serial_type accruedDays(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); static Real accruedAmount(const Leg& leg, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date()); //@} @@ -172,7 +172,7 @@ namespace QuantLib { */ static Real npv(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); //! Basis-point sensitivity of the cash flows. @@ -183,7 +183,7 @@ namespace QuantLib { */ static Real bps(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); @@ -193,7 +193,7 @@ namespace QuantLib { */ static std::pair npvbps(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); @@ -205,7 +205,7 @@ namespace QuantLib { */ static Rate atmRate(const Leg& leg, const YieldTermStructure& discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date(), Real npv = Null()); @@ -224,7 +224,7 @@ namespace QuantLib { */ static Real npv(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Real npv(const Leg& leg, @@ -232,7 +232,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); //! Basis-point sensitivity of the cash flows. @@ -245,7 +245,7 @@ namespace QuantLib { */ static Real bps(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Real bps(const Leg& leg, @@ -253,7 +253,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); //! Implied internal rate of return. @@ -266,7 +266,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date(), Real accuracy = 1.0e-10, @@ -280,7 +280,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date(), Real accuracy = 1.0e-10, @@ -318,7 +318,7 @@ namespace QuantLib { static Time duration(const Leg& leg, const InterestRate& yield, Duration::Type type, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Time duration(const Leg& leg, @@ -327,7 +327,7 @@ namespace QuantLib { Compounding compounding, Frequency frequency, Duration::Type type, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); @@ -341,7 +341,7 @@ namespace QuantLib { */ static Real convexity(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Real convexity(const Leg& leg, @@ -349,7 +349,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); @@ -359,7 +359,7 @@ namespace QuantLib { */ static Real basisPointValue(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Real basisPointValue(const Leg& leg, @@ -367,7 +367,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); @@ -378,7 +378,7 @@ namespace QuantLib { */ static Real yieldValueBasisPoint(const Leg& leg, const InterestRate& yield, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); static Real yieldValueBasisPoint(const Leg& leg, @@ -386,7 +386,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); //@} @@ -407,7 +407,7 @@ namespace QuantLib { Spread zSpread, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); /*! \deprecated Use the overload without a day counter. @@ -420,7 +420,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); //! implied Z-spread. @@ -429,7 +429,7 @@ namespace QuantLib { const ext::shared_ptr&, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date(), Real accuracy = 1.0e-10, @@ -445,7 +445,7 @@ namespace QuantLib { const DayCounter& dayCounter, Compounding compounding, Frequency frequency, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date(), Real accuracy = 1.0e-10, diff --git a/ql/cashflows/couponpricer.cpp b/ql/cashflows/couponpricer.cpp index dcd1288d383..bbfde442fd6 100644 --- a/ql/cashflows/couponpricer.cpp +++ b/ql/cashflows/couponpricer.cpp @@ -34,7 +34,7 @@ #include /* internal */ #include #include -#include +#include #include namespace QuantLib { @@ -45,7 +45,7 @@ namespace QuantLib { IborCouponPricer::IborCouponPricer( Handle v, - ext::optional useIndexedCoupon) + std::optional useIndexedCoupon) : capletVol_(std::move(v)), useIndexedCoupon_(useIndexedCoupon ? *useIndexedCoupon : diff --git a/ql/cashflows/couponpricer.hpp b/ql/cashflows/couponpricer.hpp index 15b54de0056..6075adb2537 100644 --- a/ql/cashflows/couponpricer.hpp +++ b/ql/cashflows/couponpricer.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ namespace QuantLib { public: explicit IborCouponPricer( Handle v = Handle(), - ext::optional useIndexedCoupon = ext::nullopt); + std::optional useIndexedCoupon = std::nullopt); bool useIndexedCoupon() const { return useIndexedCoupon_; } @@ -115,7 +115,7 @@ namespace QuantLib { const Handle& v = Handle(), const TimingAdjustment timingAdjustment = Black76, Handle correlation = Handle(ext::shared_ptr(new SimpleQuote(1.0))), - const ext::optional useIndexedCoupon = ext::nullopt) + const std::optional useIndexedCoupon = std::nullopt) : IborCouponPricer(v, useIndexedCoupon), timingAdjustment_(timingAdjustment), correlation_(std::move(correlation)) { { // this additional scope seems required to avoid a misleading-indentation warning diff --git a/ql/cashflows/iborcoupon.cpp b/ql/cashflows/iborcoupon.cpp index 2fb79e2ec1b..89fd5819770 100644 --- a/ql/cashflows/iborcoupon.cpp +++ b/ql/cashflows/iborcoupon.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -264,7 +264,7 @@ namespace QuantLib { return *this; } - IborLeg& IborLeg::withIndexedCoupons(ext::optional b) { + IborLeg& IborLeg::withIndexedCoupons(std::optional b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/cashflows/iborcoupon.hpp b/ql/cashflows/iborcoupon.hpp index 7b376d23a30..16922c21f8c 100644 --- a/ql/cashflows/iborcoupon.hpp +++ b/ql/cashflows/iborcoupon.hpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -159,7 +159,7 @@ namespace QuantLib { BusinessDayConvention, bool endOfMonth = false); IborLeg& withFixingConvention(BusinessDayConvention); - IborLeg& withIndexedCoupons(ext::optional b = true); + IborLeg& withIndexedCoupons(std::optional b = true); IborLeg& withAtParCoupons(bool b = true); operator Leg() const; @@ -181,7 +181,7 @@ namespace QuantLib { Calendar exCouponCalendar_; BusinessDayConvention exCouponAdjustment_ = Unadjusted; bool exCouponEndOfMonth_ = false; - ext::optional useIndexedCoupons_; + std::optional useIndexedCoupons_; }; } diff --git a/ql/cashflows/overnightindexedcoupon.cpp b/ql/cashflows/overnightindexedcoupon.cpp index 38695951195..68c16ba32cb 100644 --- a/ql/cashflows/overnightindexedcoupon.cpp +++ b/ql/cashflows/overnightindexedcoupon.cpp @@ -523,7 +523,7 @@ namespace QuantLib { return *this; } - OvernightLeg& OvernightLeg::withLastRecentPeriod(const ext::optional& lastRecentPeriod) { + OvernightLeg& OvernightLeg::withLastRecentPeriod(const std::optional& lastRecentPeriod) { lastRecentPeriod_ = lastRecentPeriod; return *this; } diff --git a/ql/cashflows/overnightindexedcoupon.hpp b/ql/cashflows/overnightindexedcoupon.hpp index cf365e10748..a43fb2a21eb 100644 --- a/ql/cashflows/overnightindexedcoupon.hpp +++ b/ql/cashflows/overnightindexedcoupon.hpp @@ -235,7 +235,7 @@ namespace QuantLib { OvernightLeg& withNakedOption(bool nakedOption); OvernightLeg& withDailyCapFloor(bool dailyCapFloor = true); OvernightLeg& inArrears(bool inArrears); - OvernightLeg& withLastRecentPeriod(const ext::optional& lastRecentPeriod); + OvernightLeg& withLastRecentPeriod(const std::optional& lastRecentPeriod); OvernightLeg& withLastRecentPeriodCalendar(const Calendar& lastRecentPeriodCalendar); OvernightLeg& withPaymentDates(const std::vector& paymentDates); OvernightLeg& withCouponPricer(const ext::shared_ptr& couponPricer); @@ -261,7 +261,7 @@ namespace QuantLib { bool nakedOption_ = false; bool dailyCapFloor_ = false; bool inArrears_ = true; - ext::optional lastRecentPeriod_; + std::optional lastRecentPeriod_; Calendar lastRecentPeriodCalendar_; std::vector paymentDates_; ext::shared_ptr couponPricer_; diff --git a/ql/config.hpp.cfg b/ql/config.hpp.cfg index 3f31e1957bb..73a77525d29 100644 --- a/ql/config.hpp.cfg +++ b/ql/config.hpp.cfg @@ -39,7 +39,6 @@ #cmakedefine QL_THROW_IN_CYCLES 1 #cmakedefine QL_USE_INDEXED_COUPON 1 #cmakedefine QL_USE_STD_ANY 1 -#cmakedefine QL_USE_STD_OPTIONAL 1 #cmakedefine QL_USE_STD_SHARED_PTR 1 #cmakedefine QL_NULL_AS_FUNCTIONS 1 diff --git a/ql/event.cpp b/ql/event.cpp index d4145a1eeb8..d8a15cc81df 100644 --- a/ql/event.cpp +++ b/ql/event.cpp @@ -20,13 +20,13 @@ #include #include -#include +#include #include namespace QuantLib { bool Event::hasOccurred(const Date& d, // refDate - ext::optional includeRefDate) const { + std::optional includeRefDate) const { Date refDate = d != Date() ? d : Settings::instance().evaluationDate(); bool includeRefDateEvent = includeRefDate ? // NOLINT(readability-implicit-bool-conversion) diff --git a/ql/event.hpp b/ql/event.hpp index ad6001b616d..0466484b39d 100644 --- a/ql/event.hpp +++ b/ql/event.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace QuantLib { @@ -52,7 +52,7 @@ namespace QuantLib { */ virtual bool hasOccurred( const Date& refDate = Date(), - ext::optional includeRefDate = ext::nullopt) const; + std::optional includeRefDate = std::nullopt) const; //@} //! \name Visitability diff --git a/ql/experimental/catbonds/montecarlocatbondengine.cpp b/ql/experimental/catbonds/montecarlocatbondengine.cpp index ab173ff28da..b86de1632c1 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.cpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -28,7 +28,7 @@ namespace QuantLib { MonteCarloCatBondEngine::MonteCarloCatBondEngine( ext::shared_ptr catRisk, Handle discountCurve, - const ext::optional& includeSettlementDateFlows) + const std::optional& includeSettlementDateFlows) : catRisk_(std::move(catRisk)), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { registerWith(discountCurve_); diff --git a/ql/experimental/catbonds/montecarlocatbondengine.hpp b/ql/experimental/catbonds/montecarlocatbondengine.hpp index b0843ccf47a..f4388e89ab5 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.hpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.hpp @@ -24,7 +24,7 @@ #ifndef quantlib_montecarlo_catbond_engine_hpp #define quantlib_montecarlo_catbond_engine_hpp -#include +#include #include namespace QuantLib { @@ -36,7 +36,7 @@ namespace QuantLib { explicit MonteCarloCatBondEngine( ext::shared_ptr catRisk, Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt); + const std::optional& includeSettlementDateFlows = std::nullopt); void calculate() const override; Handle discountCurve() const { return discountCurve_; } protected: @@ -57,7 +57,7 @@ namespace QuantLib { private: ext::shared_ptr catRisk_; Handle discountCurve_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; }; } diff --git a/ql/experimental/coupons/lognormalcmsspreadpricer.cpp b/ql/experimental/coupons/lognormalcmsspreadpricer.cpp index e0fc3ccd7f8..f16cf18be04 100644 --- a/ql/experimental/coupons/lognormalcmsspreadpricer.cpp +++ b/ql/experimental/coupons/lognormalcmsspreadpricer.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include using std::sqrt; @@ -47,7 +47,7 @@ namespace QuantLib { const Handle& correlation, Handle couponDiscountCurve, const Size integrationPoints, - const ext::optional& volatilityType, + const std::optional& volatilityType, const Real shift1, const Real shift2) : CmsSpreadCouponPricer(correlation), cmsPricer_(cmsPricer), diff --git a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp index 0e1ed52000c..ab29236efc9 100644 --- a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp +++ b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -65,7 +65,7 @@ namespace QuantLib { const Handle& correlation, Handle couponDiscountCurve = Handle(), Size IntegrationPoints = 16, - const ext::optional& volatilityType = ext::nullopt, + const std::optional& volatilityType = std::nullopt, Real shift1 = Null(), Real shift2 = Null()); diff --git a/ql/experimental/credit/syntheticcdo.cpp b/ql/experimental/credit/syntheticcdo.cpp index 2ad60bafb6a..923f4601ee7 100644 --- a/ql/experimental/credit/syntheticcdo.cpp +++ b/ql/experimental/credit/syntheticcdo.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include using namespace std; @@ -40,7 +40,7 @@ namespace QuantLib { Rate runningRate, const DayCounter& dayCounter, BusinessDayConvention paymentConvention, - ext::optional notional) + std::optional notional) : basket_(basket), side_(side), upfrontRate_(upfrontRate), runningRate_(runningRate), leverageFactor_(notional ? *notional / basket->trancheNotional() : Real(1.)), // NOLINT(readability-implicit-bool-conversion) dayCounter_(dayCounter), paymentConvention_(paymentConvention) { diff --git a/ql/experimental/credit/syntheticcdo.hpp b/ql/experimental/credit/syntheticcdo.hpp index ca4e9d6abda..60fa96a0f52 100644 --- a/ql/experimental/credit/syntheticcdo.hpp +++ b/ql/experimental/credit/syntheticcdo.hpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include @@ -122,7 +122,7 @@ namespace QuantLib { Rate runningRate, const DayCounter& dayCounter, BusinessDayConvention paymentConvention, - ext::optional notional = ext::nullopt); + std::optional notional = std::nullopt); const ext::shared_ptr& basket() const { return basket_; } diff --git a/ql/experimental/termstructures/crosscurrencyratehelpers.cpp b/ql/experimental/termstructures/crosscurrencyratehelpers.cpp index 04ee98869ca..c4b8740b994 100644 --- a/ql/experimental/termstructures/crosscurrencyratehelpers.cpp +++ b/ql/experimental/termstructures/crosscurrencyratehelpers.cpp @@ -36,14 +36,14 @@ namespace QuantLib { // Treat an explicitly-passed NoFrequency the same as an unset (nullopt) // payment frequency. Before these parameters were migrated to - // ext::optional, NoFrequency was the sentinel meaning "derive + // std::optional, NoFrequency was the sentinel meaning "derive // the schedule from the index tenor". Normalizing it here preserves that // behavior and keeps the stored optional either empty or holding an // actual frequency, so the rest of the code can treat the two cases // identically. - ext::optional normalizedPaymentFrequency(ext::optional frequency) { + std::optional normalizedPaymentFrequency(std::optional frequency) { if (frequency && *frequency == NoFrequency) - return ext::nullopt; + return std::nullopt; return frequency; } @@ -77,7 +77,7 @@ namespace QuantLib { BusinessDayConvention convention, bool endOfMonth, const ext::shared_ptr& idx, - ext::optional paymentFrequency, + std::optional paymentFrequency, Integer paymentLag) { auto overnightIndex = ext::dynamic_pointer_cast(idx); @@ -269,9 +269,9 @@ namespace QuantLib { Handle collateralCurve, bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, - ext::optional paymentFrequency, + std::optional paymentFrequency, Integer paymentLag, - ext::optional quoteCurrencyPaymentFrequency) + std::optional quoteCurrencyPaymentFrequency) : CrossCurrencySwapRateHelperBase(basis, tenor, fixingDays, std::move(calendar), convention, endOfMonth, std::move(collateralCurve), paymentLag), baseCcyIdx_(std::move(baseCurrencyIndex)), quoteCcyIdx_(std::move(quoteCurrencyIndex)), @@ -292,7 +292,7 @@ namespace QuantLib { // If no quote-currency payment frequency was given, fall back to the // base-currency payment frequency (which may itself be unset, in which // case the quote-currency leg uses its own index tenor). - ext::optional effectiveQuoteCcyFreq = + std::optional effectiveQuoteCcyFreq = quoteCcyPaymentFrequency_ ? quoteCcyPaymentFrequency_ : paymentFrequency_; quoteCcyIborLeg_ = buildFloatingLeg(evaluationDate_, tenor_, fixingDays_, calendar_, convention_, endOfMonth_, quoteCcyIdx_, effectiveQuoteCcyFreq, paymentLag_); @@ -322,9 +322,9 @@ namespace QuantLib { const Handle& collateralCurve, bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, - ext::optional paymentFrequency, + std::optional paymentFrequency, Integer paymentLag, - ext::optional quoteCurrencyPaymentFrequency) + std::optional quoteCurrencyPaymentFrequency) : CrossCurrencyBasisSwapRateHelperBase(basis, tenor, fixingDays, @@ -376,9 +376,9 @@ namespace QuantLib { bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable, - ext::optional paymentFrequency, + std::optional paymentFrequency, Integer paymentLag, - ext::optional quoteCurrencyPaymentFrequency) + std::optional quoteCurrencyPaymentFrequency) : CrossCurrencyBasisSwapRateHelperBase(basis, tenor, fixingDays, diff --git a/ql/experimental/termstructures/crosscurrencyratehelpers.hpp b/ql/experimental/termstructures/crosscurrencyratehelpers.hpp index a2e55f51ce7..ad0e4a2a732 100644 --- a/ql/experimental/termstructures/crosscurrencyratehelpers.hpp +++ b/ql/experimental/termstructures/crosscurrencyratehelpers.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace QuantLib { @@ -77,9 +77,9 @@ namespace QuantLib { Handle collateralCurve, bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, - ext::optional quoteCurrencyPaymentFrequency = ext::nullopt); + std::optional quoteCurrencyPaymentFrequency = std::nullopt); void initializeDates() override; const Handle& baseCcyLegDiscountHandle() const; @@ -89,8 +89,8 @@ namespace QuantLib { ext::shared_ptr quoteCcyIdx_; bool isFxBaseCurrencyCollateralCurrency_; bool isBasisOnFxBaseCurrencyLeg_; - ext::optional paymentFrequency_; - ext::optional quoteCcyPaymentFrequency_; + std::optional paymentFrequency_; + std::optional quoteCcyPaymentFrequency_; Leg baseCcyIborLeg_; Leg quoteCcyIborLeg_; @@ -147,9 +147,9 @@ namespace QuantLib { const Handle& collateralCurve, bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, - ext::optional quoteCurrencyPaymentFrequency = ext::nullopt); + std::optional quoteCurrencyPaymentFrequency = std::nullopt); //! \name RateHelper interface //@{ Real impliedQuote() const override; @@ -200,9 +200,9 @@ namespace QuantLib { bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, - ext::optional quoteCurrencyPaymentFrequency = ext::nullopt); + std::optional quoteCurrencyPaymentFrequency = std::nullopt); //! \name RateHelper interface //@{ Real impliedQuote() const override; diff --git a/ql/instruments/bond.cpp b/ql/instruments/bond.cpp index 48bfd4de9b1..5f27473efdf 100644 --- a/ql/instruments/bond.cpp +++ b/ql/instruments/bond.cpp @@ -106,7 +106,7 @@ namespace QuantLib { // BondFunctions. We pass nullopt as includeSettlementDateFlows // so that CashFlows::isExpired uses the default setting. return CashFlows::isExpired(cashflows_, - ext::nullopt, + std::nullopt, Settings::instance().evaluationDate()); } diff --git a/ql/instruments/callabilityschedule.hpp b/ql/instruments/callabilityschedule.hpp index 179fc619f6d..5a56e688be2 100644 --- a/ql/instruments/callabilityschedule.hpp +++ b/ql/instruments/callabilityschedule.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -57,7 +57,7 @@ namespace QuantLib { void accept(AcyclicVisitor&) override; //@} private: - ext::optional price_; + std::optional price_; Type type_; Date date_; }; diff --git a/ql/instruments/creditdefaultswap.cpp b/ql/instruments/creditdefaultswap.cpp index eb226728336..def324b2136 100644 --- a/ql/instruments/creditdefaultswap.cpp +++ b/ql/instruments/creditdefaultswap.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -50,7 +50,7 @@ namespace QuantLib { const bool rebatesAccrual, const Date& tradeDate, Natural cashSettlementDays) - : side_(side), notional_(notional), upfront_(ext::nullopt), runningSpread_(spread), + : side_(side), notional_(notional), upfront_(std::nullopt), runningSpread_(spread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(std::move(claim)), protectionStart_(protectionStart == Date() ? schedule[0] : protectionStart), @@ -187,7 +187,7 @@ namespace QuantLib { return runningSpread_; } - ext::optional CreditDefaultSwap::upfront() const { + std::optional CreditDefaultSwap::upfront() const { return upfront_; } @@ -361,7 +361,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, recoveryRate, discountCurve, - ext::nullopt, + std::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); @@ -402,7 +402,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, conventionalRecovery, discountCurve, - ext::nullopt, + std::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); diff --git a/ql/instruments/creditdefaultswap.hpp b/ql/instruments/creditdefaultswap.hpp index 1b57b826bb9..d4b4433ed5e 100644 --- a/ql/instruments/creditdefaultswap.hpp +++ b/ql/instruments/creditdefaultswap.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -176,7 +176,7 @@ namespace QuantLib { Protection::Side side() const; Real notional() const; Rate runningSpread() const; - ext::optional upfront() const; + std::optional upfront() const; bool settlesAccrual() const; bool paysAtDefaultTime() const; const Leg& coupons() const; @@ -282,7 +282,7 @@ namespace QuantLib { // data members Protection::Side side_; Real notional_; - ext::optional upfront_; + std::optional upfront_; Rate runningSpread_; bool settlesAccrual_, paysAtDefaultTime_; ext::shared_ptr claim_; @@ -314,7 +314,7 @@ namespace QuantLib { arguments(); Protection::Side side; Real notional; - ext::optional upfront; + std::optional upfront; Rate spread; Leg leg; // if not initialized by constructors means theres no flows. diff --git a/ql/instruments/fixedvsfloatingswap.cpp b/ql/instruments/fixedvsfloatingswap.cpp index e9042e5d378..0847b45039c 100644 --- a/ql/instruments/fixedvsfloatingswap.cpp +++ b/ql/instruments/fixedvsfloatingswap.cpp @@ -40,7 +40,7 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - ext::optional paymentConvention, + std::optional paymentConvention, Integer paymentLag, const Calendar& paymentCalendar) : Swap(2), type_(type), fixedNominals_(std::move(fixedNominals)), fixedSchedule_(std::move(fixedSchedule)), diff --git a/ql/instruments/fixedvsfloatingswap.hpp b/ql/instruments/fixedvsfloatingswap.hpp index cc61734154c..b1e4b08011e 100644 --- a/ql/instruments/fixedvsfloatingswap.hpp +++ b/ql/instruments/fixedvsfloatingswap.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -63,7 +63,7 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - ext::optional paymentConvention = ext::nullopt, + std::optional paymentConvention = std::nullopt, Integer paymentLag = 0, const Calendar& paymentCalendar = Calendar()); //! \name Inspectors diff --git a/ql/instruments/floatfloatswap.cpp b/ql/instruments/floatfloatswap.cpp index 6fcfb2279c6..34c9f5f3bec 100644 --- a/ql/instruments/floatfloatswap.cpp +++ b/ql/instruments/floatfloatswap.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -53,8 +53,8 @@ namespace QuantLib { const Real spread2, const Real cappedRate2, const Real flooredRate2, - const ext::optional& paymentConvention1, - const ext::optional& paymentConvention2) + const std::optional& paymentConvention1, + const std::optional& paymentConvention2) : Swap(2), type_(type), nominal1_(std::vector(schedule1.size() - 1, nominal1)), nominal2_(std::vector(schedule2.size() - 1, nominal2)), schedule1_(std::move(schedule1)), schedule2_(std::move(schedule2)), @@ -93,8 +93,8 @@ namespace QuantLib { std::vector spread2, std::vector cappedRate2, std::vector flooredRate2, - const ext::optional& paymentConvention1, - const ext::optional& paymentConvention2) + const std::optional& paymentConvention1, + const std::optional& paymentConvention2) : Swap(2), type_(type), nominal1_(std::move(nominal1)), nominal2_(std::move(nominal2)), schedule1_(std::move(schedule1)), schedule2_(std::move(schedule2)), index1_(std::move(index1)), index2_(std::move(index2)), gearing1_(std::move(gearing1)), @@ -109,8 +109,8 @@ namespace QuantLib { } void FloatFloatSwap::init( - ext::optional paymentConvention1, - ext::optional paymentConvention2) { + std::optional paymentConvention1, + std::optional paymentConvention2) { QL_REQUIRE(nominal1_.size() == schedule1_.size() - 1, "nominal1 size (" << nominal1_.size() diff --git a/ql/instruments/floatfloatswap.hpp b/ql/instruments/floatfloatswap.hpp index ebdd8cd11bd..8e7110a4b90 100644 --- a/ql/instruments/floatfloatswap.hpp +++ b/ql/instruments/floatfloatswap.hpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -65,8 +65,8 @@ namespace QuantLib { Real spread2 = 0.0, Real cappedRate2 = Null(), Real flooredRate2 = Null(), - const ext::optional& paymentConvention1 = ext::nullopt, - const ext::optional& paymentConvention2 = ext::nullopt); + const std::optional& paymentConvention1 = std::nullopt, + const std::optional& paymentConvention2 = std::nullopt); FloatFloatSwap( Swap::Type type, @@ -88,8 +88,8 @@ namespace QuantLib { std::vector spread2 = std::vector(), std::vector cappedRate2 = std::vector(), std::vector flooredRate2 = std::vector(), - const ext::optional& paymentConvention1 = ext::nullopt, - const ext::optional& paymentConvention2 = ext::nullopt); + const std::optional& paymentConvention1 = std::nullopt, + const std::optional& paymentConvention2 = std::nullopt); //! \name Inspectors //@{ @@ -134,8 +134,8 @@ namespace QuantLib { void fetchResults(const PricingEngine::results*) const override; private: - void init(ext::optional paymentConvention1, - ext::optional paymentConvention2); + void init(std::optional paymentConvention1, + std::optional paymentConvention2); void setupExpired() const override; Swap::Type type_; std::vector nominal1_, nominal2_; diff --git a/ql/instruments/makecds.hpp b/ql/instruments/makecds.hpp index 84c55cf2b24..974f42640bd 100644 --- a/ql/instruments/makecds.hpp +++ b/ql/instruments/makecds.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace QuantLib { @@ -64,9 +64,9 @@ namespace QuantLib { MakeCreditDefaultSwap& withPricingEngine(const ext::shared_ptr&); private: - ext::optional tenor_; - ext::optional termDate_; - ext::optional schedule_; + std::optional tenor_; + std::optional termDate_; + std::optional schedule_; Real runningSpread_; Protection::Side side_ = Protection::Buyer; Real nominal_ = 1.0; diff --git a/ql/instruments/makeois.hpp b/ql/instruments/makeois.hpp index 05c4ba402bf..f527408e321 100644 --- a/ql/instruments/makeois.hpp +++ b/ql/instruments/makeois.hpp @@ -118,7 +118,7 @@ namespace QuantLib { DateGeneration::Rule fixedRule_ = DateGeneration::Backward; DateGeneration::Rule overnightRule_ = DateGeneration::Backward; bool fixedEndOfMonth_ = false, overnightEndOfMonth_ = false, isDefaultEOM_ = true; - ext::optional maturityEndOfMonth_; + std::optional maturityEndOfMonth_; Swap::Type type_ = Swap::Payer; Real nominal_ = 1.0; diff --git a/ql/instruments/makeswaption.cpp b/ql/instruments/makeswaption.cpp index 6a88f4441d1..7b7d3bf80c5 100644 --- a/ql/instruments/makeswaption.cpp +++ b/ql/instruments/makeswaption.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -188,7 +188,7 @@ namespace QuantLib { return *this; } - MakeSwaption& MakeSwaption::withIndexedCoupons(const ext::optional& b) { + MakeSwaption& MakeSwaption::withIndexedCoupons(const std::optional& b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/instruments/makeswaption.hpp b/ql/instruments/makeswaption.hpp index c02b1089096..7a320ef3480 100644 --- a/ql/instruments/makeswaption.hpp +++ b/ql/instruments/makeswaption.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace QuantLib { @@ -62,7 +62,7 @@ namespace QuantLib { MakeSwaption& withExerciseDate(const Date&); MakeSwaption& withExerciseCalendar(const Calendar&); MakeSwaption& withUnderlyingType(Swap::Type type); - MakeSwaption& withIndexedCoupons(const ext::optional& b = true); + MakeSwaption& withIndexedCoupons(const std::optional& b = true); MakeSwaption& withAtParCoupons(bool b = true); MakeSwaption& withPricingEngine( @@ -83,7 +83,7 @@ namespace QuantLib { Rate strike_; Swap::Type underlyingType_; Real nominal_; - ext::optional useIndexedCoupons_; + std::optional useIndexedCoupons_; ext::shared_ptr engine_; }; diff --git a/ql/instruments/makevanillaswap.cpp b/ql/instruments/makevanillaswap.cpp index 23a62e9397c..01f11abec51 100644 --- a/ql/instruments/makevanillaswap.cpp +++ b/ql/instruments/makevanillaswap.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -371,7 +371,7 @@ namespace QuantLib { return *this; } - MakeVanillaSwap& MakeVanillaSwap::withIndexedCoupons(const ext::optional& b) { + MakeVanillaSwap& MakeVanillaSwap::withIndexedCoupons(const std::optional& b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/instruments/makevanillaswap.hpp b/ql/instruments/makevanillaswap.hpp index 4de6432b244..5ef15ee0787 100644 --- a/ql/instruments/makevanillaswap.hpp +++ b/ql/instruments/makevanillaswap.hpp @@ -84,7 +84,7 @@ namespace QuantLib { const Handle& discountCurve); MakeVanillaSwap& withPricingEngine( const ext::shared_ptr& engine); - MakeVanillaSwap& withIndexedCoupons(const ext::optional& b = true); + MakeVanillaSwap& withIndexedCoupons(const std::optional& b = true); MakeVanillaSwap& withAtParCoupons(bool b = true); private: Period swapTenor_; @@ -105,13 +105,13 @@ namespace QuantLib { DateGeneration::Rule fixedRule_ = DateGeneration::Backward, floatRule_ = DateGeneration::Backward; bool fixedEndOfMonth_ = false, floatEndOfMonth_ = false; - ext::optional maturityEndOfMonth_; + std::optional maturityEndOfMonth_; Date fixedFirstDate_, fixedNextToLastDate_; Date floatFirstDate_, floatNextToLastDate_; Spread floatSpread_ = 0.0; DayCounter fixedDayCount_, floatDayCount_; - ext::optional useIndexedCoupons_; - ext::optional paymentConvention_; + std::optional useIndexedCoupons_; + std::optional paymentConvention_; ext::shared_ptr engine_; }; diff --git a/ql/instruments/multipleresetsswap.cpp b/ql/instruments/multipleresetsswap.cpp index f2d08985f72..fc9cb39bf61 100644 --- a/ql/instruments/multipleresetsswap.cpp +++ b/ql/instruments/multipleresetsswap.cpp @@ -41,7 +41,7 @@ namespace QuantLib { Schedule fullResetSchedule, const ext::shared_ptr& iborIndex, Size resetsPerCoupon, Spread spread, RateAveraging::Type averagingMethod, - ext::optional paymentConvention, + std::optional paymentConvention, Integer paymentLag, const Calendar& paymentCalendar) : FixedVsFloatingSwap(type, std::vector(fixedSchedule.size() - 1, nominal), diff --git a/ql/instruments/multipleresetsswap.hpp b/ql/instruments/multipleresetsswap.hpp index 7d25b2d6c79..1a4fb6de5ae 100644 --- a/ql/instruments/multipleresetsswap.hpp +++ b/ql/instruments/multipleresetsswap.hpp @@ -49,7 +49,7 @@ namespace QuantLib { Size resetsPerCoupon, Spread spread = 0.0, RateAveraging::Type averagingMethod = RateAveraging::Compound, - ext::optional paymentConvention = ext::nullopt, + std::optional paymentConvention = std::nullopt, Integer paymentLag = 0, const Calendar& paymentCalendar = Calendar()); diff --git a/ql/instruments/nonstandardswap.cpp b/ql/instruments/nonstandardswap.cpp index 520dd1f08e6..b474f9573f3 100644 --- a/ql/instruments/nonstandardswap.cpp +++ b/ql/instruments/nonstandardswap.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -68,7 +68,7 @@ namespace QuantLib { DayCounter floatingDayCount, const bool intermediateCapitalExchange, const bool finalCapitalExchange, - ext::optional paymentConvention) + std::optional paymentConvention) : Swap(2), type_(type), fixedNominal_(std::move(fixedNominal)), floatingNominal_(floatingNominal), fixedSchedule_(std::move(fixedSchedule)), fixedRate_(std::move(fixedRate)), fixedDayCount_(std::move(fixedDayCount)), @@ -99,7 +99,7 @@ namespace QuantLib { DayCounter floatingDayCount, const bool intermediateCapitalExchange, const bool finalCapitalExchange, - ext::optional paymentConvention) + std::optional paymentConvention) : Swap(2), type_(type), fixedNominal_(std::move(fixedNominal)), floatingNominal_(std::move(floatingNominal)), fixedSchedule_(std::move(fixedSchedule)), fixedRate_(std::move(fixedRate)), fixedDayCount_(std::move(fixedDayCount)), diff --git a/ql/instruments/nonstandardswap.hpp b/ql/instruments/nonstandardswap.hpp index c7ed4a7350b..c1895313184 100644 --- a/ql/instruments/nonstandardswap.hpp +++ b/ql/instruments/nonstandardswap.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -56,7 +56,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - ext::optional paymentConvention = ext::nullopt); + std::optional paymentConvention = std::nullopt); NonstandardSwap(Swap::Type type, std::vector fixedNominal, std::vector floatingNominal, @@ -70,7 +70,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - ext::optional paymentConvention = ext::nullopt); + std::optional paymentConvention = std::nullopt); //! \name Inspectors //@{ Swap::Type type() const; diff --git a/ql/instruments/overnightindexedswap.cpp b/ql/instruments/overnightindexedswap.cpp index e01d877d2d0..b75872deaf4 100644 --- a/ql/instruments/overnightindexedswap.cpp +++ b/ql/instruments/overnightindexedswap.cpp @@ -144,7 +144,7 @@ namespace QuantLib { bool applyObservationShift) : FixedVsFloatingSwap(type, std::move(fixedNominals), std::move(fixedSchedule), fixedRate, std::move(fixedDC), overnightNominals, std::move(overnightSchedule), overnightIndex, - spread, DayCounter(), ext::nullopt, paymentLag, paymentCalendar), + spread, DayCounter(), std::nullopt, paymentLag, paymentCalendar), overnightIndex_(overnightIndex), paymentLag_(paymentLag), paymentCalendar_(paymentCalendar), telescopicValueDates_(telescopicValueDates), diff --git a/ql/instruments/vanillaswap.cpp b/ql/instruments/vanillaswap.cpp index 0ba87a70785..15bd895c638 100644 --- a/ql/instruments/vanillaswap.cpp +++ b/ql/instruments/vanillaswap.cpp @@ -36,8 +36,8 @@ namespace QuantLib { ext::shared_ptr index, Spread spread, DayCounter floatingDayCount, - ext::optional paymentConvention, - ext::optional useIndexedCoupons) + std::optional paymentConvention, + std::optional useIndexedCoupons) : FixedVsFloatingSwap(type, {nominal}, std::move(fixedSchedule), fixedRate, std::move(fixedDayCount), {nominal}, std::move(floatSchedule), std::move(index), spread, std::move(floatingDayCount), paymentConvention) { diff --git a/ql/instruments/vanillaswap.hpp b/ql/instruments/vanillaswap.hpp index 7370a5f5aef..12137458b77 100644 --- a/ql/instruments/vanillaswap.hpp +++ b/ql/instruments/vanillaswap.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -73,8 +73,8 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - ext::optional paymentConvention = ext::nullopt, - ext::optional useIndexedCoupons = ext::nullopt); + std::optional paymentConvention = std::nullopt, + std::optional useIndexedCoupons = std::nullopt); private: void setupFloatingArguments(arguments* args) const override; diff --git a/ql/optional.hpp b/ql/optional.hpp index 5039db8837d..1498fe7ffaf 100644 --- a/ql/optional.hpp +++ b/ql/optional.hpp @@ -17,36 +17,12 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file optional.hpp - \brief Maps optional to either the boost or std implementation -*/ - #ifndef quantlib_optional_hpp #define quantlib_optional_hpp -#include - -#if defined(QL_USE_STD_OPTIONAL) -#include -#else -#if BOOST_VERSION >= 109100 -#error Boost 1.91 introduced changes in boost::optional that silently changed the behavior of our code and would cause it to work incorrectly. Use std::optional instead. -#endif // Deprecated in version 1.39 -#pragma message("Warning: using boost::optional is deprecated. Enable std::optional instead.") -#include -#endif - -namespace QuantLib::ext { +#pragma message("Warning: this file is empty and will disappear in a future release; use #include instead.") - #if defined(QL_USE_STD_OPTIONAL) - using std::optional; // NOLINT(misc-unused-using-decls) - inline constexpr const std::nullopt_t& nullopt = std::nullopt; - #else - using boost::optional; // NOLINT(misc-unused-using-decls) - inline constexpr const boost::none_t& nullopt = boost::none; - #endif - - } +#include #endif diff --git a/ql/pricingengines/bond/discountingbondengine.cpp b/ql/pricingengines/bond/discountingbondengine.cpp index 9d36ecf72fc..4096744cfe2 100644 --- a/ql/pricingengines/bond/discountingbondengine.cpp +++ b/ql/pricingengines/bond/discountingbondengine.cpp @@ -20,14 +20,14 @@ #include #include -#include +#include #include namespace QuantLib { DiscountingBondEngine::DiscountingBondEngine( Handle discountCurve, - const ext::optional& includeSettlementDateFlows) + const std::optional& includeSettlementDateFlows) : discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { registerWith(discountCurve_); diff --git a/ql/pricingengines/bond/discountingbondengine.hpp b/ql/pricingengines/bond/discountingbondengine.hpp index 3c221c661a0..d4ff4a1812f 100644 --- a/ql/pricingengines/bond/discountingbondengine.hpp +++ b/ql/pricingengines/bond/discountingbondengine.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -40,14 +40,14 @@ namespace QuantLib { public: DiscountingBondEngine( Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt); + const std::optional& includeSettlementDateFlows = std::nullopt); void calculate() const override; Handle discountCurve() const { return discountCurve_; } private: Handle discountCurve_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/capfloor/analyticcapfloorengine.cpp b/ql/pricingengines/capfloor/analyticcapfloorengine.cpp index 697e5dfe345..1617400282d 100644 --- a/ql/pricingengines/capfloor/analyticcapfloorengine.cpp +++ b/ql/pricingengines/capfloor/analyticcapfloorengine.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include namespace QuantLib { @@ -54,7 +54,7 @@ namespace QuantLib { bool includeRefDatePayments = Settings::instance().includeReferenceDateEvents(); if (referenceDate == Settings::instance().evaluationDate()) { - ext::optional includeTodaysPayments = + std::optional includeTodaysPayments = Settings::instance().includeTodaysCashFlows(); if (includeTodaysPayments) // NOLINT(readability-implicit-bool-conversion) includeRefDatePayments = *includeTodaysPayments; diff --git a/ql/pricingengines/credit/integralcdsengine.cpp b/ql/pricingengines/credit/integralcdsengine.cpp index 0d307b1a1bc..c55a4934622 100644 --- a/ql/pricingengines/credit/integralcdsengine.cpp +++ b/ql/pricingengines/credit/integralcdsengine.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -32,7 +32,7 @@ namespace QuantLib { Handle probability, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows) + const std::optional& includeSettlementDateFlows) : integrationStep_(step), probability_(std::move(probability)), recoveryRate_(recoveryRate), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { diff --git a/ql/pricingengines/credit/integralcdsengine.hpp b/ql/pricingengines/credit/integralcdsengine.hpp index 24c885f1b79..42aaeaae8d4 100644 --- a/ql/pricingengines/credit/integralcdsengine.hpp +++ b/ql/pricingengines/credit/integralcdsengine.hpp @@ -26,7 +26,7 @@ #define quantlib_integral_cds_engine_hpp #include -#include +#include namespace QuantLib { @@ -36,7 +36,7 @@ namespace QuantLib { Handle, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt); + const std::optional& includeSettlementDateFlows = std::nullopt); void calculate() const override; private: @@ -44,7 +44,7 @@ namespace QuantLib { Handle probability_; Real recoveryRate_; Handle discountCurve_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/credit/isdacdsengine.cpp b/ql/pricingengines/credit/isdacdsengine.cpp index 5f807edd596..b18b8dd0542 100644 --- a/ql/pricingengines/credit/isdacdsengine.cpp +++ b/ql/pricingengines/credit/isdacdsengine.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -36,7 +36,7 @@ namespace QuantLib { IsdaCdsEngine::IsdaCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, const NumericalFix numericalFix, const AccrualBias accrualBias, const ForwardsInCouponPeriod forwardsInCouponPeriod) diff --git a/ql/pricingengines/credit/isdacdsengine.hpp b/ql/pricingengines/credit/isdacdsengine.hpp index ccd1369b7c5..0ea2913257e 100644 --- a/ql/pricingengines/credit/isdacdsengine.hpp +++ b/ql/pricingengines/credit/isdacdsengine.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -98,7 +98,7 @@ namespace QuantLib { IsdaCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, NumericalFix numericalFix = Taylor, AccrualBias accrualBias = HalfDayBias, ForwardsInCouponPeriod forwardsInCouponPeriod = Piecewise); @@ -112,7 +112,7 @@ namespace QuantLib { Handle probability_; const Real recoveryRate_; Handle discountCurve_; - const ext::optional includeSettlementDateFlows_; + const std::optional includeSettlementDateFlows_; const NumericalFix numericalFix_; const AccrualBias accrualBias_; const ForwardsInCouponPeriod forwardsInCouponPeriod_; diff --git a/ql/pricingengines/credit/midpointcdsengine.cpp b/ql/pricingengines/credit/midpointcdsengine.cpp index 1facad68d25..753207560b1 100644 --- a/ql/pricingengines/credit/midpointcdsengine.cpp +++ b/ql/pricingengines/credit/midpointcdsengine.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -31,7 +31,7 @@ namespace QuantLib { MidPointCdsEngine::MidPointCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows) + const std::optional& includeSettlementDateFlows) : probability_(std::move(probability)), recoveryRate_(recoveryRate), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { diff --git a/ql/pricingengines/credit/midpointcdsengine.hpp b/ql/pricingengines/credit/midpointcdsengine.hpp index a1a7e36b029..9601a67743b 100644 --- a/ql/pricingengines/credit/midpointcdsengine.hpp +++ b/ql/pricingengines/credit/midpointcdsengine.hpp @@ -27,7 +27,7 @@ #define quantlib_mid_point_cds_engine_hpp #include -#include +#include namespace QuantLib { @@ -36,14 +36,14 @@ namespace QuantLib { MidPointCdsEngine(Handle, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt); + const std::optional& includeSettlementDateFlows = std::nullopt); void calculate() const override; private: Handle probability_; Real recoveryRate_; Handle discountCurve_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/futures/discountingperpetualfuturesengine.hpp b/ql/pricingengines/futures/discountingperpetualfuturesengine.hpp index 52d53ecc038..7fccac234c9 100644 --- a/ql/pricingengines/futures/discountingperpetualfuturesengine.hpp +++ b/ql/pricingengines/futures/discountingperpetualfuturesengine.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include namespace QuantLib { diff --git a/ql/pricingengines/mclongstaffschwartzengine.hpp b/ql/pricingengines/mclongstaffschwartzengine.hpp index 5126044fde2..9999252ad5d 100644 --- a/ql/pricingengines/mclongstaffschwartzengine.hpp +++ b/ql/pricingengines/mclongstaffschwartzengine.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -80,8 +80,8 @@ namespace QuantLib { Size maxSamples, BigNatural seed, Size nCalibrationSamples = Null(), - ext::optional brownianBridgeCalibration = ext::nullopt, - ext::optional antitheticVariateCalibration = ext::nullopt, + std::optional brownianBridgeCalibration = std::nullopt, + std::optional antitheticVariateCalibration = std::nullopt, BigNatural seedCalibration = Null()); void calculate() const override; @@ -131,8 +131,8 @@ namespace QuantLib { Size maxSamples, BigNatural seed, Size nCalibrationSamples, - ext::optional brownianBridgeCalibration, - ext::optional antitheticVariateCalibration, + std::optional brownianBridgeCalibration, + std::optional antitheticVariateCalibration, BigNatural seedCalibration) : McSimulation(antitheticVariate, controlVariate), process_(std::move(process)), timeSteps_(timeSteps), timeStepsPerYear_(timeStepsPerYear), brownianBridge_(brownianBridge), diff --git a/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.cpp b/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.cpp index b4bd77e3fef..e7b677962a9 100644 --- a/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.cpp +++ b/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.cpp @@ -27,7 +27,7 @@ namespace QuantLib { DiscountingConstNotionalCrossCurrencySwapEngine::DiscountingConstNotionalCrossCurrencySwapEngine(Currency domesticCcy, const Handle& domesticCcyDiscountcurve, Currency foreignCcy, const Handle& foreignCcyDiscountcurve, - const Handle& spotFX, ext::optional includeSettlementDateFlows, + const Handle& spotFX, std::optional includeSettlementDateFlows, const Date& settlementDate, const Date& npvDate, const Date& spotFXSettleDate) : domesticCcy_(std::move(domesticCcy)), domesticCcyDiscountcurve_(domesticCcyDiscountcurve), foreignCcy_(std::move(foreignCcy)), foreignCcyDiscountcurve_(foreignCcyDiscountcurve), spotFX_(spotFX), diff --git a/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.hpp b/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.hpp index ae21b518964..22d7f7a4cc7 100644 --- a/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.hpp +++ b/ql/pricingengines/swap/discountingconstnotionalcrosscurrencyswapengine.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -68,7 +68,7 @@ class DiscountingConstNotionalCrossCurrencySwapEngine : public ConstNotionalCros */ DiscountingConstNotionalCrossCurrencySwapEngine(Currency domesticCcy, const Handle& domesticCcyDiscountCurve, Currency foreignCcy, const Handle& foreignCcyDiscountCurve, - const Handle& spotFX, ext::optional includeSettlementDateFlows = ext::nullopt, + const Handle& spotFX, std::optional includeSettlementDateFlows = std::nullopt, const Date& settlementDate = Date(), const Date& npvDate = Date(), const Date& spotFXSettleDate = Date()); //@} @@ -94,7 +94,7 @@ class DiscountingConstNotionalCrossCurrencySwapEngine : public ConstNotionalCros Currency foreignCcy_; Handle foreignCcyDiscountcurve_; Handle spotFX_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; Date settlementDate_; Date npvDate_; Date spotFXSettleDate_; diff --git a/ql/pricingengines/swap/discountingswapengine.cpp b/ql/pricingengines/swap/discountingswapengine.cpp index d74cf5843df..7264e8b60dd 100644 --- a/ql/pricingengines/swap/discountingswapengine.cpp +++ b/ql/pricingengines/swap/discountingswapengine.cpp @@ -21,14 +21,14 @@ #include #include #include -#include +#include #include namespace QuantLib { DiscountingSwapEngine::DiscountingSwapEngine( Handle discountCurve, - const ext::optional& includeSettlementDateFlows, + const std::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) : discountCurve_(std::move(discountCurve)), diff --git a/ql/pricingengines/swap/discountingswapengine.hpp b/ql/pricingengines/swap/discountingswapengine.hpp index 3943fda632c..93e896ab7ba 100644 --- a/ql/pricingengines/swap/discountingswapengine.hpp +++ b/ql/pricingengines/swap/discountingswapengine.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -40,7 +40,7 @@ namespace QuantLib { public: DiscountingSwapEngine( Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt, + const std::optional& includeSettlementDateFlows = std::nullopt, Date settlementDate = Date(), Date npvDate = Date()); void calculate() const override; @@ -49,7 +49,7 @@ namespace QuantLib { } private: Handle discountCurve_; - ext::optional includeSettlementDateFlows_; + std::optional includeSettlementDateFlows_; Date settlementDate_, npvDate_; }; diff --git a/ql/pricingengines/vanilla/mcamericanengine.hpp b/ql/pricingengines/vanilla/mcamericanengine.hpp index fc06574b1f2..9354d08263e 100644 --- a/ql/pricingengines/vanilla/mcamericanengine.hpp +++ b/ql/pricingengines/vanilla/mcamericanengine.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,7 +65,7 @@ namespace QuantLib { Size polynomialOrder, LsmBasisSystem::PolynomialType polynomialType, Size nCalibrationSamples = Null(), - const ext::optional& antitheticVariateCalibration = ext::nullopt, + const std::optional& antitheticVariateCalibration = std::nullopt, BigNatural seedCalibration = Null()); void calculate() const override; @@ -134,7 +134,7 @@ namespace QuantLib { BigNatural seed_ = 0; Size polynomialOrder_ = 2; LsmBasisSystem::PolynomialType polynomialType_ = LsmBasisSystem::Monomial; - ext::optional antitheticCalibration_; + std::optional antitheticCalibration_; BigNatural seedCalibration_; }; @@ -152,7 +152,7 @@ namespace QuantLib { Size polynomialOrder, LsmBasisSystem::PolynomialType polynomialType, Size nCalibrationSamples, - const ext::optional& antitheticVariateCalibration, + const std::optional& antitheticVariateCalibration, BigNatural seedCalibration) : MCLongstaffSchwartzEngine( process, @@ -269,7 +269,7 @@ namespace QuantLib { ext::shared_ptr process) : process_(std::move(process)), steps_(Null()), stepsPerYear_(Null()), samples_(Null()), maxSamples_(Null()), tolerance_(Null()), - antitheticCalibration_(ext::nullopt), seedCalibration_(Null()) {} + antitheticCalibration_(std::nullopt), seedCalibration_(Null()) {} template inline MakeMCAmericanEngine & diff --git a/ql/quantlib.hpp b/ql/quantlib.hpp index 37e3274479d..4555eb20ca0 100644 --- a/ql/quantlib.hpp +++ b/ql/quantlib.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/ql/settings.hpp b/ql/settings.hpp index 8a730209142..3253bbcc2ee 100644 --- a/ql/settings.hpp +++ b/ql/settings.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -102,8 +102,8 @@ namespace QuantLib { behavior chosen for includeReferenceDate. It cannot be overridden locally when calling the CashFlow::hasOccurred method. */ - ext::optional& includeTodaysCashFlows(); - ext::optional includeTodaysCashFlows() const; + std::optional& includeTodaysCashFlows(); + std::optional includeTodaysCashFlows() const; bool& enforcesTodaysHistoricFixings(); bool enforcesTodaysHistoricFixings() const; @@ -111,7 +111,7 @@ namespace QuantLib { private: DateProxy evaluationDate_; bool includeReferenceDateEvents_ = false; - ext::optional includeTodaysCashFlows_; + std::optional includeTodaysCashFlows_; bool enforcesTodaysHistoricFixings_ = false; }; @@ -124,7 +124,7 @@ namespace QuantLib { private: Date evaluationDate_; bool includeReferenceDateEvents_; - ext::optional includeTodaysCashFlows_; + std::optional includeTodaysCashFlows_; bool enforcesTodaysHistoricFixings_; }; @@ -160,11 +160,11 @@ namespace QuantLib { return includeReferenceDateEvents_; } - inline ext::optional& Settings::includeTodaysCashFlows() { + inline std::optional& Settings::includeTodaysCashFlows() { return includeTodaysCashFlows_; } - inline ext::optional Settings::includeTodaysCashFlows() const { + inline std::optional Settings::includeTodaysCashFlows() const { return includeTodaysCashFlows_; } diff --git a/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.cpp b/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.cpp index ea96bfe250c..64a02aaaf03 100644 --- a/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.cpp +++ b/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.cpp @@ -36,10 +36,10 @@ namespace QuantLib { const std::vector& callDeltas, bool hasAtm, const Matrix& blackVolMatrix, const DayCounter& dayCounter, const Calendar& cal, const Handle& spot, const Handle& domesticTS, const Handle& foreignTS, DeltaVolQuote::DeltaType deltaType, DeltaVolQuote::AtmType atmType, - ext::optional atmDeltaType, SmileInterpolationMethod im, + std::optional atmDeltaType, SmileInterpolationMethod im, bool flatStrikeExtrapolation, BlackVolTimeExtrapolation::Type timeExtrapolationType, const Period& switchTenor, DeltaVolQuote::DeltaType longTermDeltaType, DeltaVolQuote::AtmType longTermAtmType, - ext::optional longTermAtmDeltaType) + std::optional longTermAtmDeltaType) : BlackVolatilityTermStructure(referenceDate, cal, Following, dayCounter), dates_(dates), times_(dates.size(), 0), putDeltas_(putDeltas), callDeltas_(callDeltas), hasAtm_(hasAtm), spot_(spot), domesticTS_(domesticTS), foreignTS_(foreignTS), deltaType_(deltaType), atmType_(atmType), atmDeltaType_(atmDeltaType ? *atmDeltaType : deltaType), diff --git a/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.hpp b/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.hpp index aa84afbfcc8..1e19cacf485 100644 --- a/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.hpp +++ b/ql/termstructures/volatility/equityfx/blackvolsurfacedelta.hpp @@ -91,7 +91,7 @@ namespace QuantLib { const Handle& foreignTS, DeltaVolQuote::DeltaType deltaType = DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType atmType = DeltaVolQuote::AtmType::AtmDeltaNeutral, - ext::optional atmDeltaType = ext::nullopt, + std::optional atmDeltaType = std::nullopt, SmileInterpolationMethod interpolationMethod = SmileInterpolationMethod::Linear, bool flatStrikeExtrapolation = false, @@ -100,7 +100,7 @@ namespace QuantLib { const Period& switchTenor = 0 * Days, DeltaVolQuote::DeltaType longTermDeltaType = DeltaVolQuote::DeltaType::Fwd, DeltaVolQuote::AtmType longTermAtmType = DeltaVolQuote::AtmType::AtmDeltaNeutral, - ext::optional longTermAtmDeltaType = ext::nullopt); + std::optional longTermAtmDeltaType = std::nullopt); //@} //! \name TermStructure interface diff --git a/ql/termstructures/volatility/optionlet/optionletstripper.cpp b/ql/termstructures/volatility/optionlet/optionletstripper.cpp index c404faa11a4..611a672e39a 100644 --- a/ql/termstructures/volatility/optionlet/optionletstripper.cpp +++ b/ql/termstructures/volatility/optionlet/optionletstripper.cpp @@ -33,7 +33,7 @@ namespace QuantLib { Handle discount, const VolatilityType type, const Real displacement, - ext::optional optionletFrequency + std::optional optionletFrequency ) : termVolSurface_(termVolSurface), iborIndex_(std::move(iborIndex)), discount_(std::move(discount)), nStrikes_(termVolSurface->strikes().size()), @@ -170,7 +170,7 @@ namespace QuantLib { return volatilityType_; } - ext::optional OptionletStripper::optionletFrequency() const { + std::optional OptionletStripper::optionletFrequency() const { return optionletFrequency_; } diff --git a/ql/termstructures/volatility/optionlet/optionletstripper.hpp b/ql/termstructures/volatility/optionlet/optionletstripper.hpp index 5b013cf9931..8490f2543e3 100644 --- a/ql/termstructures/volatility/optionlet/optionletstripper.hpp +++ b/ql/termstructures/volatility/optionlet/optionletstripper.hpp @@ -64,7 +64,7 @@ namespace QuantLib { ext::shared_ptr iborIndex() const; Real displacement() const override; VolatilityType volatilityType() const override; - ext::optional optionletFrequency() const; + std::optional optionletFrequency() const; protected: OptionletStripper(const ext::shared_ptr&, @@ -72,7 +72,7 @@ namespace QuantLib { Handle discount = {}, VolatilityType type = ShiftedLognormal, Real displacement = 0.0, - ext::optional optionletFrequency = ext::nullopt); + std::optional optionletFrequency = std::nullopt); ext::shared_ptr termVolSurface_; ext::shared_ptr iborIndex_; Handle discount_; @@ -92,7 +92,7 @@ namespace QuantLib { std::vector capFloorLengths_; const VolatilityType volatilityType_; const Real displacement_; - ext::optional optionletFrequency_; + std::optional optionletFrequency_; }; } diff --git a/ql/termstructures/volatility/optionlet/optionletstripper1.cpp b/ql/termstructures/volatility/optionlet/optionletstripper1.cpp index 58bb76b5004..5bb602b5e40 100644 --- a/ql/termstructures/volatility/optionlet/optionletstripper1.cpp +++ b/ql/termstructures/volatility/optionlet/optionletstripper1.cpp @@ -44,7 +44,7 @@ namespace QuantLib { const VolatilityType type, const Real displacement, bool dontThrow, - ext::optional optionletFrequency) + std::optional optionletFrequency) : OptionletStripper(termVolSurface, index, discount, type, displacement, optionletFrequency), floatingSwitchStrike_(switchStrike == Null()), switchStrike_(switchStrike), accuracy_(accuracy), maxIter_(maxIter), dontThrow_(dontThrow) { diff --git a/ql/termstructures/volatility/optionlet/optionletstripper1.hpp b/ql/termstructures/volatility/optionlet/optionletstripper1.hpp index a61c9ae07ff..7693f7c66cb 100644 --- a/ql/termstructures/volatility/optionlet/optionletstripper1.hpp +++ b/ql/termstructures/volatility/optionlet/optionletstripper1.hpp @@ -53,7 +53,7 @@ namespace QuantLib { VolatilityType type = ShiftedLognormal, Real displacement = 0.0, bool dontThrow = false, - ext::optional optionletFrequency = ext::nullopt); + std::optional optionletFrequency = std::nullopt); const Matrix& capFloorPrices() const; const Matrix &capletVols() const; diff --git a/ql/termstructures/yield/oisratehelper.cpp b/ql/termstructures/yield/oisratehelper.cpp index 9e92a8711fc..fa21c634703 100644 --- a/ql/termstructures/yield/oisratehelper.cpp +++ b/ql/termstructures/yield/oisratehelper.cpp @@ -45,8 +45,8 @@ namespace QuantLib { Pillar::Choice pillar, Date customPillarDate, RateAveraging::Type averagingMethod, - ext::optional endOfMonth, - ext::optional fixedPaymentFrequency, + std::optional endOfMonth, + std::optional fixedPaymentFrequency, Calendar fixedCalendar, Natural lookbackDays, Natural lockoutDays, @@ -83,8 +83,8 @@ namespace QuantLib { Pillar::Choice pillar, Date customPillarDate, RateAveraging::Type averagingMethod, - ext::optional endOfMonth, - ext::optional fixedPaymentFrequency, + std::optional endOfMonth, + std::optional fixedPaymentFrequency, Calendar fixedCalendar, Natural lookbackDays, Natural lockoutDays, diff --git a/ql/termstructures/yield/oisratehelper.hpp b/ql/termstructures/yield/oisratehelper.hpp index d880e65f524..4326334b829 100644 --- a/ql/termstructures/yield/oisratehelper.hpp +++ b/ql/termstructures/yield/oisratehelper.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include namespace QuantLib { @@ -54,8 +54,8 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), RateAveraging::Type averagingMethod = RateAveraging::Compound, - ext::optional endOfMonth = ext::nullopt, - ext::optional fixedPaymentFrequency = ext::nullopt, + std::optional endOfMonth = std::nullopt, + std::optional fixedPaymentFrequency = std::nullopt, Calendar fixedCalendar = Calendar(), Natural lookbackDays = Null(), Natural lockoutDays = 0, @@ -81,8 +81,8 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), RateAveraging::Type averagingMethod = RateAveraging::Compound, - ext::optional endOfMonth = ext::nullopt, - ext::optional fixedPaymentFrequency = ext::nullopt, + std::optional endOfMonth = std::nullopt, + std::optional fixedPaymentFrequency = std::nullopt, Calendar fixedCalendar = Calendar(), Natural lookbackDays = Null(), Natural lockoutDays = 0, @@ -131,8 +131,8 @@ namespace QuantLib { Handle overnightSpread_; Pillar::Choice pillarChoice_; RateAveraging::Type averagingMethod_; - ext::optional endOfMonth_; - ext::optional fixedPaymentFrequency_; + std::optional endOfMonth_; + std::optional fixedPaymentFrequency_; Calendar fixedCalendar_; Calendar overnightCalendar_; BusinessDayConvention convention_; diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index 76637201361..f2f04d56905 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -466,7 +466,7 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const ext::optional& useIndexedCoupons) + const std::optional& useIndexedCoupons) : SwapRateHelper(rate, swapIndex->tenor(), swapIndex->fixingCalendar(), swapIndex->fixedLegTenor().frequency(), swapIndex->fixedLegConvention(), swapIndex->dayCounter(), swapIndex->iborIndex(), std::move(spread), fwdStart, @@ -487,8 +487,8 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const ext::optional& useIndexedCoupons, - const ext::optional& floatConvention) + const std::optional& useIndexedCoupons, + const std::optional& floatConvention) : RelativeDateRateHelper(rate), settlementDays_(settlementDays), tenor_(tenor), pillarChoice_(pillarChoice), calendar_(std::move(calendar)), fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency), @@ -511,8 +511,8 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const ext::optional& useIndexedCoupons, - const ext::optional& floatConvention) + const std::optional& useIndexedCoupons, + const std::optional& floatConvention) : RelativeDateRateHelper(rate, false), startDate_(startDate), endDate_(endDate), pillarChoice_(pillarChoice), calendar_(std::move(calendar)), fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency), diff --git a/ql/termstructures/yield/ratehelpers.hpp b/ql/termstructures/yield/ratehelpers.hpp index 3a242cf3577..2877f49d4d0 100644 --- a/ql/termstructures/yield/ratehelpers.hpp +++ b/ql/termstructures/yield/ratehelpers.hpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -183,8 +183,8 @@ namespace QuantLib { private: void initializeDates() override; Date fixingDate_; - ext::optional periodToStart_; - ext::optional immOffsetStart_, immOffsetEnd_; + std::optional periodToStart_; + std::optional immOffsetStart_, immOffsetEnd_; Pillar::Choice pillarChoice_; ext::shared_ptr iborIndex_; RelinkableHandle termStructureHandle_; @@ -206,7 +206,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt); + const std::optional& useIndexedCoupons = std::nullopt); SwapRateHelper(const std::variant>& rate, const Period& tenor, Calendar calendar, @@ -224,8 +224,8 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt, - const ext::optional& floatConvention = ext::nullopt); + const std::optional& useIndexedCoupons = std::nullopt, + const std::optional& floatConvention = std::nullopt); SwapRateHelper(const std::variant>& rate, const Date& startDate, const Date& endDate, @@ -242,8 +242,8 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt, - const ext::optional& floatConvention = ext::nullopt); + const std::optional& useIndexedCoupons = std::nullopt, + const std::optional& floatConvention = std::nullopt); //! \name RateHelper interface //@{ Real impliedQuote() const override; @@ -280,8 +280,8 @@ namespace QuantLib { Period fwdStart_; Handle discountHandle_; RelinkableHandle discountRelinkableHandle_; - ext::optional useIndexedCoupons_; - ext::optional floatConvention_; + std::optional useIndexedCoupons_; + std::optional floatConvention_; }; diff --git a/ql/termstructures/yield/ultimateforwardtermstructure.hpp b/ql/termstructures/yield/ultimateforwardtermstructure.hpp index f283cb86744..9bf1da73e73 100644 --- a/ql/termstructures/yield/ultimateforwardtermstructure.hpp +++ b/ql/termstructures/yield/ultimateforwardtermstructure.hpp @@ -25,7 +25,7 @@ #define quantlib_ultimate_forward_term_structure_hpp #include -#include +#include #include #include #include @@ -82,7 +82,7 @@ namespace QuantLib { Handle ultimateForwardRate, const Period& firstSmoothingPoint, Real alpha, - const ext::optional& roundingDigits = ext::nullopt, + const std::optional& roundingDigits = std::nullopt, Compounding compounding = Compounded, Frequency frequency = Annual); //! \name YieldTermStructure interface @@ -111,7 +111,7 @@ namespace QuantLib { Handle ufr_; Period fsp_; Real alpha_; - ext::optional roundingDigits_; + std::optional roundingDigits_; Compounding compounding_; Frequency frequency_; }; @@ -124,7 +124,7 @@ namespace QuantLib { Handle ultimateForwardRate, const Period& firstSmoothingPoint, Real alpha, - const ext::optional& roundingDigits, + const std::optional& roundingDigits, Compounding compounding, Frequency frequency) : originalCurve_(std::move(h)), llfr_(std::move(lastLiquidForwardRate)), diff --git a/ql/time/schedule.cpp b/ql/time/schedule.cpp index e2bf7fd6cd0..b5ab4711c1f 100644 --- a/ql/time/schedule.cpp +++ b/ql/time/schedule.cpp @@ -19,7 +19,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include +#include #include #include #include @@ -53,10 +53,10 @@ namespace QuantLib { Schedule::Schedule(const std::vector& dates, Calendar calendar, BusinessDayConvention convention, - const ext::optional& terminationDateConvention, - const ext::optional& tenor, - const ext::optional& rule, - const ext::optional& endOfMonth, + const std::optional& terminationDateConvention, + const std::optional& tenor, + const std::optional& rule, + const std::optional& endOfMonth, std::vector isRegular) : tenor_(tenor), calendar_(std::move(calendar)), convention_(convention), terminationDateConvention_(terminationDateConvention), rule_(rule), dates_(dates), diff --git a/ql/time/schedule.hpp b/ql/time/schedule.hpp index 194f3c4bb8a..2f32caf7552 100644 --- a/ql/time/schedule.hpp +++ b/ql/time/schedule.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -47,10 +47,10 @@ namespace QuantLib { const std::vector&, Calendar calendar = NullCalendar(), BusinessDayConvention convention = Unadjusted, - const ext::optional& terminationDateConvention = ext::nullopt, - const ext::optional& tenor = ext::nullopt, - const ext::optional& rule = ext::nullopt, - const ext::optional& endOfMonth = ext::nullopt, + const std::optional& terminationDateConvention = std::nullopt, + const std::optional& tenor = std::nullopt, + const std::optional& rule = std::nullopt, + const std::optional& endOfMonth = std::nullopt, std::vector isRegular = std::vector(0)); /*! rule based constructor */ Schedule(Date effectiveDate, @@ -109,12 +109,12 @@ namespace QuantLib { Schedule until(const Date& truncationDate) const; //@} private: - ext::optional tenor_; + std::optional tenor_; Calendar calendar_; BusinessDayConvention convention_; - ext::optional terminationDateConvention_; - ext::optional rule_; - ext::optional endOfMonth_; + std::optional terminationDateConvention_; + std::optional rule_; + std::optional endOfMonth_; Date firstDate_, nextToLastDate_; std::vector dates_; std::vector isRegular_; @@ -144,9 +144,9 @@ namespace QuantLib { private: Calendar calendar_; Date effectiveDate_, terminationDate_; - ext::optional tenor_; - ext::optional convention_; - ext::optional terminationDateConvention_; + std::optional tenor_; + std::optional convention_; + std::optional terminationDateConvention_; DateGeneration::Rule rule_ = DateGeneration::Backward; bool endOfMonth_ = false; Date firstDate_, nextToLastDate_; diff --git a/ql/userconfig.hpp b/ql/userconfig.hpp index bc42ae169eb..174802d5010 100644 --- a/ql/userconfig.hpp +++ b/ql/userconfig.hpp @@ -127,15 +127,6 @@ # define QL_USE_STD_ANY #endif -/* If defined, `std::optional` and related classes and functions will - be used instead of `boost::optional`. If undefined, the Boost - facilities will be used; however, be aware that Boost 1.91 - introduced changes in boost::optional that silently changed the - behavior of our code and would cause it to work incorrectly. -*/ -#ifndef QL_USE_STD_OPTIONAL -# define QL_USE_STD_OPTIONAL -#endif /* If defined, `std::shared_ptr` and related classes and functions will used instead of `boost::shared_ptr`. If undefined, the Boost diff --git a/test-suite/blackvolsurfacedelta.cpp b/test-suite/blackvolsurfacedelta.cpp index 4e5dc27d496..0fe9f493374 100644 --- a/test-suite/blackvolsurfacedelta.cpp +++ b/test-suite/blackvolsurfacedelta.cpp @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(testTimeExtrapolation) { BlackVolatilitySurfaceDelta surface1(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, BlackVolTimeExtrapolation::FlatVolatility); QL_CHECK_CLOSE(surface1.blackVol(refDate + Period(2, Years), atmStrike), 0.095, 1e-8); @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(testTimeExtrapolation) { BlackVolatilitySurfaceDelta surface2(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, BlackVolTimeExtrapolation::LinearVariance); QL_CHECK_CLOSE(surface2.blackVol(refDate + Period(2, Years), atmStrike), 0.095, 1e-8); @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(testTimeExtrapolation) { BlackVolatilitySurfaceDelta surface3(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, BlackVolTimeExtrapolation::UseInterpolator); surface3.enableExtrapolation(); @@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(testSmileInterpolation) { BlackVolatilitySurfaceDelta surface1(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::Linear, false, BlackVolTimeExtrapolation::FlatVolatility); auto smile = surface1.blackVolSmile(refDate + Period(6, Months)); @@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(testSmileInterpolation) { BlackVolatilitySurfaceDelta surface2(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::NaturalCubic, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::NaturalCubic, false, BlackVolTimeExtrapolation::FlatVolatility); smile = surface2.blackVolSmile(refDate + Period(6, Months)); @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(testSmileInterpolation) { BlackVolatilitySurfaceDelta surface3(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::FinancialCubic, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::FinancialCubic, false, BlackVolTimeExtrapolation::FlatVolatility); smile = surface3.blackVolSmile(refDate + Period(6, Months)); @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(testSmileInterpolation) { BlackVolatilitySurfaceDelta surface4(refDate, dates, putDeltas, callDeltas, hasAtm, vols, ActualActual(ActualActual::ISDA), TARGET(), spot, dts, fts, DeltaVolQuote::DeltaType::Spot, DeltaVolQuote::AtmType::AtmSpot, - ext::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::CubicSpline, false, + std::nullopt, BlackVolatilitySurfaceDelta::SmileInterpolationMethod::CubicSpline, false, BlackVolTimeExtrapolation::FlatVolatility); smile = surface4.blackVolSmile(refDate + Period(6, Months)); diff --git a/test-suite/cashflows.cpp b/test-suite/cashflows.cpp index ebd1d30d723..c429248ba4b 100644 --- a/test-suite/cashflows.cpp +++ b/test-suite/cashflows.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include using namespace QuantLib; @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(testSettings) { // today's date Settings::instance().includeReferenceDateEvents() = false; - Settings::instance().includeTodaysCashFlows() = ext::nullopt; + Settings::instance().includeTodaysCashFlows() = std::nullopt; CHECK_INCLUSION(0, 0, false); CHECK_INCLUSION(0, 1, false); @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(testSettings) { // today's date Settings::instance().includeReferenceDateEvents() = true; - Settings::instance().includeTodaysCashFlows() = ext::nullopt; + Settings::instance().includeTodaysCashFlows() = std::nullopt; CHECK_INCLUSION(0, 0, true); CHECK_INCLUSION(0, 1, false); @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(testSettings) { } while (false); // no override - Settings::instance().includeTodaysCashFlows() = ext::nullopt; + Settings::instance().includeTodaysCashFlows() = std::nullopt; CHECK_NPV(false, 2.0); CHECK_NPV(true, 3.0); @@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(testPartialScheduleLegConstruction) { .backwards(); // same schedule, date based, with metadata Schedule schedule2(schedule.dates(), NullCalendar(), Unadjusted, Unadjusted, - 6 * Months, ext::nullopt, schedule.endOfMonth(), + 6 * Months, std::nullopt, schedule.endOfMonth(), schedule.isRegular()); // same schedule, date based, without metadata Schedule schedule3(schedule.dates()); diff --git a/test-suite/creditdefaultswap.cpp b/test-suite/creditdefaultswap.cpp index ccc1f72fa2f..066c9bec79f 100644 --- a/test-suite/creditdefaultswap.cpp +++ b/test-suite/creditdefaultswap.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -684,7 +684,7 @@ BOOST_AUTO_TEST_CASE(testIsdaEngine) { ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, std::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -827,7 +827,7 @@ BOOST_AUTO_TEST_CASE(testIsdaCalculatorReconcileSingleQuote) { ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, std::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -939,7 +939,7 @@ BOOST_AUTO_TEST_CASE(testIsdaCalculatorReconcileSingleWithIssueDateInThePast) { ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, std::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = diff --git a/test-suite/crosscurrencyratehelpers.cpp b/test-suite/crosscurrencyratehelpers.cpp index d0b3bf740a0..257e31503cb 100644 --- a/test-suite/crosscurrencyratehelpers.cpp +++ b/test-suite/crosscurrencyratehelpers.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,10 +114,10 @@ struct CommonVars { bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, bool useOvernightIndex = false, - ext::optional quoteCcyPaymentFrequency = ext::nullopt) const { + std::optional quoteCcyPaymentFrequency = std::nullopt) const { Handle quoteHandle(ext::make_shared(q.basis * basisPoint)); Period tenor(q.n, q.units); ext::shared_ptr baseIndex, quoteIndex; @@ -142,10 +142,10 @@ struct CommonVars { bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, bool useOvernightQuoteIndex = false, - ext::optional quoteCcyPaymentFrequency = ext::nullopt) const { + std::optional quoteCcyPaymentFrequency = std::nullopt) const { std::vector > instruments; instruments.reserve(xccyData.size()); for (const auto& i : xccyData) { @@ -314,10 +314,10 @@ void testConstantNotionalCrossCurrencySwapsNPV(bool isFxBaseCurrencyCollateralCu void testResettingCrossCurrencySwaps(bool isFxBaseCurrencyCollateralCurrency, bool isBasisOnFxBaseCurrencyLeg, bool isFxBaseCurrencyLegResettable, - ext::optional paymentFrequency = ext::nullopt, + std::optional paymentFrequency = std::nullopt, Integer paymentLag = 0, bool useOvernightIndex = false, - ext::optional quoteCcyPaymentFrequency = ext::nullopt) { + std::optional quoteCcyPaymentFrequency = std::nullopt) { CommonVars vars; @@ -499,8 +499,8 @@ BOOST_AUTO_TEST_CASE(testResettingBasisSwapsTreatNoFrequencyAsUnset) { std::vector > defaultInstruments = vars.buildResettingXccyRateHelpers( vars.basisData, collateralHandle, isFxBaseCurrencyCollateralCurrency, - isBasisOnFxBaseCurrencyLeg, isFxBaseCurrencyLegResettable, ext::nullopt, 0, false, - ext::nullopt); + isBasisOnFxBaseCurrencyLeg, isFxBaseCurrencyLegResettable, std::nullopt, 0, false, + std::nullopt); // An explicit NoFrequency on both legs must behave identically. Before // NoFrequency was normalized to nullopt it built a single-period schedule @@ -555,7 +555,7 @@ BOOST_AUTO_TEST_CASE(testResettingBasisSwapsQuoteFrequencyDefaultsToBase) { vars.buildResettingXccyRateHelpers( vars.basisData, collateralHandle, isFxBaseCurrencyCollateralCurrency, isBasisOnFxBaseCurrencyLeg, isFxBaseCurrencyLegResettable, baseFrequency, 0, false, - ext::nullopt); + std::nullopt); // Quote-currency frequency set explicitly to the base frequency: same result. std::vector > explicitInstruments = @@ -596,7 +596,7 @@ BOOST_AUTO_TEST_CASE(testResettingBasisSwapsWithPaymentLag) { bool isBasisOnFxBaseCurrencyLeg = true; testResettingCrossCurrencySwaps(isFxBaseCurrencyCollateralCurrency, isBasisOnFxBaseCurrencyLeg, - isFxBaseCurrencyLegResettable, ext::nullopt, 2); + isFxBaseCurrencyLegResettable, std::nullopt, 2); } BOOST_AUTO_TEST_CASE(testResettingBasisSwapsWithOvernightIndex) { @@ -621,7 +621,7 @@ BOOST_AUTO_TEST_CASE(testResettingBasisSwapsWithOvernightIndexException) { BOOST_CHECK_THROW(testResettingCrossCurrencySwaps( isFxBaseCurrencyCollateralCurrency, isBasisOnFxBaseCurrencyLeg, - isFxBaseCurrencyLegResettable, ext::nullopt, 0, true), + isFxBaseCurrencyLegResettable, std::nullopt, 0, true), Error); } diff --git a/test-suite/defaultprobabilitycurves.cpp b/test-suite/defaultprobabilitycurves.cpp index 8d44478409b..ba4b6a798e6 100644 --- a/test-suite/defaultprobabilitycurves.cpp +++ b/test-suite/defaultprobabilitycurves.cpp @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(testUpfrontBootstrap) { // This checks that UpfrontCdsHelper::impliedQuote() didn't // override the flag permanently; after the bootstrap, it should // go back to its previous value. - ext::optional flag = Settings::instance().includeTodaysCashFlows(); + std::optional flag = Settings::instance().includeTodaysCashFlows(); if (flag != false) BOOST_ERROR("Cash-flow settings improperly modified"); } diff --git a/test-suite/overnightindexedswap.cpp b/test-suite/overnightindexedswap.cpp index a065295afe9..f3566b24042 100644 --- a/test-suite/overnightindexedswap.cpp +++ b/test-suite/overnightindexedswap.cpp @@ -456,8 +456,8 @@ BOOST_AUTO_TEST_CASE(testBootstrapWithCustomPricer) { Pillar::LastRelevantDate, Date(), averagingMethod, - ext::nullopt, - ext::nullopt, + std::nullopt, + std::nullopt, Calendar(), Null(), 0, @@ -527,8 +527,8 @@ void testBootstrapWithLookback(Natural lookbackDays, Pillar::LastRelevantDate, Date(), RateAveraging::Compound, - ext::nullopt, - ext::nullopt, + std::nullopt, + std::nullopt, Calendar(), lookbackDays, lockoutDays, @@ -763,7 +763,7 @@ for (auto & i : data) { false, 0, Following, Annual, calendar, 0*Days, 0.0, Pillar::LastRelevantDate, Date(), - RateAveraging::Compound, ext::nullopt, ext::nullopt, + RateAveraging::Compound, std::nullopt, std::nullopt, calendar, Null(), 0, false, ext::shared_ptr(), DateGeneration::Backward, calendar)); diff --git a/test-suite/period.cpp b/test-suite/period.cpp index 2b790e5a25b..6a7c24ac7e7 100644 --- a/test-suite/period.cpp +++ b/test-suite/period.cpp @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(testNormalization) { for (Period p2 : test_values) { auto n2 = p2.normalized(); - ext::optional comparison; + std::optional comparison; try { comparison = (p1 == p2); } catch (Error&) { diff --git a/test-suite/quantlibglobalfixture.cpp b/test-suite/quantlibglobalfixture.cpp index d7a078998b6..0d25eab253b 100644 --- a/test-suite/quantlibglobalfixture.cpp +++ b/test-suite/quantlibglobalfixture.cpp @@ -39,7 +39,7 @@ namespace { */ // QuantLib::Settings::instance().includeReferenceDateCashFlows() = true; - // QuantLib::Settings::instance().includeTodaysCashFlows() = ext::nullopt; + // QuantLib::Settings::instance().includeTodaysCashFlows() = std::nullopt; QuantLib::Settings::instance().evaluationDate() = evaluationDate; } diff --git a/test-suite/ultimateforwardtermstructure.cpp b/test-suite/ultimateforwardtermstructure.cpp index 08e2cbb821f..8405401eb01 100644 --- a/test-suite/ultimateforwardtermstructure.cpp +++ b/test-suite/ultimateforwardtermstructure.cpp @@ -138,7 +138,7 @@ Rate calculateExtrapolatedForward(Time t, Time fsp, Rate llfr, Rate ufr, Real al } void checkDutchBankRates(const std::vector& expectedRates, - const ext::optional& rounding = ext::nullopt, + const std::optional& rounding = std::nullopt, Compounding compounding = Compounded, Frequency frequency = Annual, Real tolerance = 1.0e-4) {