Use nested struct to provide constexpr constants#286
Closed
jwnimmer-tri wants to merge 1 commit intogazebosim:mainfrom
Closed
Use nested struct to provide constexpr constants#286jwnimmer-tri wants to merge 1 commit intogazebosim:mainfrom
jwnimmer-tri wants to merge 1 commit intogazebosim:mainfrom
Conversation
Deprecate the non-constexpr spelling of the constants.
7 tasks
Contributor
Author
|
Thanks for taking this on @jwnimmer-tri . I'm taking a look at both approaches and will let you know what I prefer, at least. |
Contributor
Author
|
Closing in lieu of #283. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Colorexists 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
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge