Migrate ext::optional → std::optional and remove Boost optional shim#6
Open
tobydrinkall wants to merge 1 commit into
Open
Migrate ext::optional → std::optional and remove Boost optional shim#6tobydrinkall wants to merge 1 commit into
tobydrinkall wants to merge 1 commit into
Conversation
Replace all ext::optional<T> with std::optional<T> and ext::nullopt with std::nullopt across 79 source files. Replace #include <ql/optional.hpp> with #include <optional>. Tombstone ql/optional.hpp to a thin deprecated #include <optional> (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 <toby.drinkall@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the highest-priority modernization: replaces all
ext::optional/ext::nulloptwithstd::optional/std::nulloptand removes the now-deadQL_USE_STD_OPTIONALbuild flag. This eliminates the correctness landmine inql/optional.hppthat#errors on Boost ≥ 1.91 due to silent pricing-behavior changes inboost::optional.Why this shim first:
optionalsits on public, price-affecting APIs —Settings::includeTodaysCashFlows_(controls NPV inclusion) andEvent::hasOccurred(Date, optional<bool>)(controls accrual logic). A wrong empty-state semantics silently misprices.What changed (93 files, ~79 source files + config/docs)
ext::optional<T>→std::optional<T>,ext::nullopt→std::nullopt,#include <ql/optional.hpp>→#include <optional>across allql/andtest-suite/.hpp/.cppfiles.ql/optional.hpp: reduced to a deprecated#include <optional>(matchesfunctional.hpp/tuple.hpppattern).QL_USE_STD_OPTIONALfrom:CMakeLists.txt,CMakePresets.json,configure.ac,ql/userconfig.hpp,ql/config.hpp.cfg,.ci/userconfig{2019,2022,2026}.alt.hpp,Docs/pages/config.docs.AGENTS.mdandDocs/pages/modernization.docsto reflect the completed migration and point to the next shim (any, thenshared_ptr).Blast radius by layer
settings,event,cashflow)cashflows/*instruments/*pricingengines/*termstructures/*experimental/*,time/*test-suite/*Densest consumer:
ql/cashflows/cashflows.cpp(44ext::optional→std::optionalreplacements).Verification (local — CI is disabled on this fork)
cmake --build build -j$(nproc))ext::optional,ext::nullopt,boost::optional, orQL_USE_STD_OPTIONALin source filesLink to Devin session: https://app.devin.ai/sessions/f937f3023be0434396b95fabd8eaeeab
Requested by: @tobydrinkall
Devin Review