Skip to content

Add constexpr support to internal::sorted_map and internal::sorted_set #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 3, 2022

Conversation

wravery
Copy link
Contributor

@wravery wravery commented May 2, 2022

Fix #139

Unfortunately, constexpr support for std::vector seems to be lagging behind in GCC and AppleClang, so I was only able to do this by extracting some of the lookup logic an templatizing it on the container and iterator types in internal::sorted_map_equal_range and internal::sorted_map_lookup. That way it can apply the same logic to perform lookups against a std::array<std::pair<K, V>> as it would for an internal::sorted_map<K, V>.

The only place where I've actually adopted this is in the generated enum value maps, but this should make looking up an enum value O(log(n)) instead of O(n) at runtime. It also lets you perform compile time mapping between the strings and their enum values.

@wravery wravery merged commit c47cd51 into microsoft:main May 3, 2022
@wravery wravery deleted the constexpr-sorted branch May 3, 2022 00:00
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.

improve static data structures
1 participant