Use nested struct to provide constexpr constants #286
Closed
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.
🦟 Bug fix
A portion of #269.
Summary
Use constexpr for simple static constants, to avoid the C++ global static construction and destruction order fiascos.
This is an alternative approach vs #283. Due to MSVC's apparent limitiations, the only way to provide inline static constants is via a helper struct (or namespace-scoped globals), so that the
class Color
exists as a complete type prior to declaring constants that use it.Deprecate the const-only (non-constexpr) spelling of the constants.
At the moment, only Color has been refactored with this pattern while we discuss the implications.
In this version of the fix, we have an API+ABI break (with a deprecation transition), and thus will require users to refactor their code. In the #283 version of the fix, we remain API compatible (but still break ABI).
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge