Skip to content

Conversation

@Ivorforce
Copy link
Member

Previously, to use Variant in a HashMap (or AHashMap or HashSet), you'd have to supply it with the hasher and comparator explicitly.

I change the implementation to specialise HashMapHasherDefault and HashMapComparatorDefault. Hence, HashMap can simply be used as HashMap<Variant, X> for the default case.

…ing `HashMapHasherDefault` and `HashMapComparatorDefault`.
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Makes sense to me, but it's worth noting that (like any removal of APIs from headers) this breaks compatibility for thirdparty modules or platforms and user forks who may make use of it.

I'm starting to think that we may need to collect information on all those changes to core headers done recently to add to a subpage of the 4.6 migration guide for C++ engine modifications.

@akien-mga akien-mga modified the milestones: 4.x, 4.6 Oct 9, 2025
@Ivorforce
Copy link
Member Author

Makes sense to me, but it's worth noting that (like any removal of APIs from headers) this breaks compatibility for thirdparty modules or platforms and user forks who may make use of it.

I'm starting to think that we may need to collect information on all those changes to core headers done recently to add to a subpage of the 4.6 migration guide for C++ engine modifications.

It would be possible to add a [[deprecated]] version of the removed structures, which would save modules from compile issues. Should I add it?

@Repiteo
Copy link
Contributor

Repiteo commented Oct 9, 2025

Ehh, I don't think that's necessary. Though if you really want to have some contingency, appending this to the end of variant.h would suffice:

#ifndef DISABLE_DEPRECATED
// Compatibility with pre-4.6 modules.
using VariantHasher = HashMapHasherDefault<Variant>;
using VariantComparator = HashMapComparatorDefault<Variant>;
#endif // DISABLE_DEPRECATED

See also: an equivalent implementation in version.h for GODOT_ defines.

@Repiteo Repiteo merged commit 16a11ac into godotengine:master Oct 10, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 10, 2025

Thanks!

@Ivorforce Ivorforce deleted the no-variant-hasher branch October 10, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants