refactor: migrate ext::optional to std::optional, remove QL_USE_STD_OPTIONAL#2
Open
tobydrinkall wants to merge 5 commits into
Open
refactor: migrate ext::optional to std::optional, remove QL_USE_STD_OPTIONAL#2tobydrinkall wants to merge 5 commits into
tobydrinkall wants to merge 5 commits into
Conversation
…nullopt Mechanical text replacements across 80 source files: - ext::optional<T> -> std::optional<T> - ext::nullopt -> std::nullopt - #include <ql/optional.hpp> -> #include <optional> The ext:: aliases were a compatibility shim mapping to either boost::optional or std::optional depending on QL_USE_STD_OPTIONAL. Since std::optional is now universally available (C++17), all call sites are updated to use the standard type directly. No functional changes: with QL_USE_STD_OPTIONAL=ON (the default), ext::optional was already a using-declaration for std::optional. Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Remove the QL_USE_STD_OPTIONAL toggle from all build system files:
- CMakeLists.txt: option() declaration and QL_USE_STD_CLASSES shortcut
- configure.ac: --enable-std-optional AC_ARG_ENABLE block and std-classes define
- CMakePresets.json: two preset cache variable entries
- ql/userconfig.hpp: #define block and documentation comment
- ql/config.hpp.cfg: #cmakedefine line
- .ci/userconfig{2019,2022,2026}.alt.hpp: conditional #define blocks
- Docs/pages/config.docs: documentation paragraph
After commit 1, no code references ext::optional — all call sites use
std::optional directly. The conditional compilation gate is dead code.
ql/optional.hpp still compiles (it reads QL_USE_STD_OPTIONAL) but will
be simplified in the next commit.
Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
Replace the conditional boost/std dispatch with a plain forwarding header that: - Emits a #pragma message deprecation warning on inclusion - Includes <optional> unconditionally - Retains the QuantLib::ext:: aliases for downstream compatibility The boost::optional code path and QL_USE_STD_OPTIONAL guard are removed. Third-party code that includes <ql/optional.hpp> or uses ext::optional will still compile but will see the deprecation warning guiding them to migrate to std::optional. 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:
|
…ion warning Remove ql/optional.hpp from ql/Makefile.am and ql/quantlib.hpp so that the #pragma message deprecation warning does not fire for every translation unit that includes the umbrella header. The deprecated ql/optional.hpp remains available for explicit inclusion by downstream code that hasn't migrated yet. Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
…brella header Restore optional.hpp to ql/Makefile.am so autotools still installs it (matching ql/CMakeLists.txt). Add an exclusion in GenerateHeaders.cmake so the CMake-generated ql/quantlib.hpp skips it. Both build systems now: - Install the deprecated header (backward compat for downstream code) - Exclude it from the umbrella header (no noisy #pragma warnings) Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
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
Complete migration from
ext::optional/ext::nullopttostd::optional/std::nulloptacross the entire codebase. Theext::aliases were a compatibility shim mapping to eitherboost::optionalorstd::optionaldepending onQL_USE_STD_OPTIONAL. Since C++17 is now required (CMAKE_CXX_STANDARD 17), the indirection is unnecessary.Structured commits
1.
refactor:mechanical text replacements (80 files, ±345 lines)No functional change — with
QL_USE_STD_OPTIONAL=ON(the default),ext::optionalwas already ausingdeclaration forstd::optional.2.
build:removeQL_USE_STD_OPTIONALfrom build configuration (9 files, −60 lines)CMakeLists.txt—option()+QL_USE_STD_CLASSESshortcutconfigure.ac—--enable-std-optionalblock +--enable-std-classesdefineCMakePresets.json— two preset cache entriesql/userconfig.hpp,ql/config.hpp.cfg—#define/#cmakedefine.ci/userconfig{2019,2022,2026}.alt.hpp— conditional#defineblocksDocs/pages/config.docs— documentation paragraphAfter commit 1, no source references
ext::optional, so the toggle is dead code.3.
deprecate:simplifyql/optional.hppto a forwarding headerReplaces the conditional boost/std dispatch with:
#pragma messagedeprecation warning#include <optional>QuantLib::ext::aliases for downstream compatibility4–5.
fix:umbrella header cleanupPer review feedback: removed
ql/optional.hppfrom the auto-generated umbrella header (cmake/GenerateHeaders.cmakeexclusion +ql/quantlib.hppedit) to avoid noisy deprecation warnings, while keeping the header installable in both CMake and autotools for backward compatibility.Dependency ordering
Each phase is independently buildable:
QL_USE_STD_OPTIONAL=ON(default) meantext::optionalwas alreadystd::optionalql/optional.hppis only included viaql/quantlib.hpp(the umbrella header) after commit 1#pragmadoesn't fire through the umbrella headerVerification
ctestsuite: 100% tests passed (284s, identical to 287s baseline)Link to Devin session: https://app.devin.ai/sessions/4b1b94a613fe4adfaa8868760eaff1ff
Requested by: @tobydrinkall
Devin Review