Delete VariantGetInternalPtr
and VariantImplicitConvert
, replace with VariantInternalAccessor
#105254
+955
−1,474
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.
Includes / supersedes #105246.
I recommend looking briefly at the above PR, but merging this one (without merging the above first), because it ultimately creates the better end picture.
Explanation
VariantGetInternalPtr
,VariantImplicitConvert
(introduced temporarily in #105246) andVariantInternalAccessor
do pretty much the same thing: They allow users to get values and assign values when working withVariant
, when the underlying type is known to match.Having 3 types for the same task is not a great idea, because code will diverge. In this PR, I am deduplicating functionality by deleting
VariantGetInternalPtr
andVariantImplicitConvert
, and merely usingVariantInternalAccessor
in all cases.Doing this allows us to confidently maintain
VariantInternalAccessor
going forwards, instead of having to maintain a convoluted mess of different ways to do the same thing.The PR is big and scary, but almost all of the changes are pretty safe search-and-replace.
Notes
Through search-and-replace, some
VariantInternalAccessor
uses ended up using the following style:VariantInternalAccessor<A>::get(variant) = b; // Instead of VariantInternalAccessor<A>::set(variant, b);
This looks a bit weird, but it's not detrimental to performance, using a reference to assign to the value. This can get cleaned up if it's confusing in the future.