Skip to content

More constexpr schema #234

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 6 commits into from
Apr 23, 2022
Merged

Conversation

wravery
Copy link
Contributor

@wravery wravery commented Apr 23, 2022

Additional changes on top of #227. The biggest difference is that I wrapped the static constexpr variables in constexpr functions to simplify the scoping and give them a nicer public name.

The ...Schema.cpp files still share a single static instance of the enum names. Callers of the getEnumNames() constexpr functions will need to do something similar with a local variable (or a shared static if that makes sense) to use iterators on the array of names, otherwise each call to getEnumNames() returns a new instance in a temporary variable, and the iterators don't match the container. If, OTOH, you are just plugging it into a template parameter or passing it as a single argument to another function, it should be fine to just substitute a call to getEnumNames() for the reference to the static s_namesEnum instance which #227 would have declared in the header.

@wravery wravery merged commit 2c1a677 into microsoft:main Apr 23, 2022
@wravery wravery deleted the more-constexpr-schema branch September 10, 2024 20:08
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.

2 participants