Fix #9386: use variant instead of unique_ptr to prevent compilers failing on the code generation #9391
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.
Motivation / Problem
In the words of TB:
Description
Fixes #9386 by using
std::variant
to forego the need to generate code for anew
and as such needing to bother withdelete
at a later stage.The forwarding constructor of
std::variant
is quite picky (at least on MSVC). It does not like to resolve overloaded functions, so some functions needed to be renamed to be resolvable. Furthermore the 'naked' initializer forSaveLoad
was causing issues at some places, so effectively 'name' it by addingSaveLoad
to the SLE* macros.Finally resolving from a variant to a type is not super trivial when you do not know the exact type, for this
std::visit
is used which helps but including that in a simpleiterator
is beyond my C++-foo, so fell back to a helper function to convert the type of the 'auto loop' to the needed/wantedconst SettingDesc *
.Limitations
std::visit
requires Mac OS 10.14 or higher which has been out-of-support for half a year... and that causes deprecations warnings that I can't solve.Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.