Skip to content

refactor: modernize ext::optional shim to std::optional (C++17), remove QL_USE_STD_OPTIONAL#5

Open
tobydrinkall wants to merge 9 commits into
masterfrom
devin/1780665255-migrate-std-optional
Open

refactor: modernize ext::optional shim to std::optional (C++17), remove QL_USE_STD_OPTIONAL#5
tobydrinkall wants to merge 9 commits into
masterfrom
devin/1780665255-migrate-std-optional

Conversation

@tobydrinkall
Copy link
Copy Markdown

@tobydrinkall tobydrinkall commented Jun 5, 2026

Summary

Replaces all ext::optional/ext::nullopt usages with std::optional/std::nullopt directly, removes the dead QL_USE_STD_OPTIONAL build flag (it was already defaulted ON), and reduces ql/optional.hpp to a thin deprecated forwarding header (#include <optional>).

Since QL_USE_STD_OPTIONAL was ON by default, ext::optional already resolved to std::optional — so this is a type-alias-only change with zero semantic impact. The Boost path (boost::optional) is eliminated; it was already guarded by a #error on Boost ≥ 1.91 due to silent behavior changes.


Dependency Blast Radius

Metric Count
ext::optional occurrences migrated 261
ext::nullopt occurrences migrated 130
#include <ql/optional.hpp>#include <optional> 53
Total files touched 81
QL_USE_STD_OPTIONAL references removed 18 (9 files)

Migration Order (commits follow this bottom-up order, each builds green)

  1. Core (settings.hpp, event.hpp, cashflow.hpp + .cpp) — price-control APIs
  2. cashflows/ (8 files)
  3. instruments/ (21 files)
  4. pricingengines/ (16 files)
  5. termstructures/ (11 files)
  6. experimental/ + time/ (10 files)
  7. test-suite/ (9 files)
  8. Swap all #include directives
  9. Remove QL_USE_STD_OPTIONAL from build system + reduce shim

Flag Teardown

Removed from: CMakeLists.txt, CMakePresets.json (both *-nonstandard-options presets), configure.ac, ql/userconfig.hpp, ql/config.hpp.cfg, .ci/userconfig{2019,2022,2026}.alt.hpp, Docs/pages/config.docs.


Verification Results

Test-suite: 100% passed, 0 failed (182 suites / 1,321 cases, 306.85s).

Numeric equivalence (master vs branch, 20 examples):

Example Result
EquityOption, Bonds, BermudanSwaption, FRA, MulticurveBootstrapping, CDS IDENTICAL
AsianOption, BasketLosses, CVAIRS, CallableBonds, ConvertibleBonds IDENTICAL
FittedBondCurve, Gaussian1dModels, LatentModel, MarketModels IDENTICAL
MultidimIntegral, Replication, Repo IDENTICAL
DiscreteHedging, GlobalOptimizer inherently non-deterministic*

18/18 deterministic examples: byte-identical (2,147 total lines compared).

*DiscreteHedging (MC) and GlobalOptimizer (differential evolution) are inherently non-deterministic: two sequential runs of the same master binary also produce different output, confirming stochastic RNG-seeded processes unrelated to the migration.

Zero leftovers:

grep 'ext::optional\|ext::nullopt' ql/ test-suite/  → 0
grep 'QL_USE_STD_OPTIONAL' (source)                 → 0
grep 'boost::optional\|boost::none' (source)        → 0

Link to Devin session: https://app.devin.ai/sessions/a007a5cdfb1842729b8875e744ed3b8b
Requested by: @tobydrinkall


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)
Open in Devin Review

devin-ai-integration Bot and others added 9 commits June 5, 2026 13:17
…ent/cashflow

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
…ss all files

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
…o deprecated forwarding header

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant