-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use templates for common geometric constants #7558
base: master
Are you sure you want to change the base?
Conversation
You should use |
Updated to account for `<numbers>` and C++20: - Marked all `lmms_constants.h` constants with an exact equivalent in `<numbers>` as deprecated - Removed all `lmms_constants.h` constants where no variant is currently in use - Using `inline constexpr` - Using `std::floating_point` concept instead of `typename`
Updated to account for
|
This won't work. I suggested waiting for C++20 and the compiler upgrade since we are in the process of doing that now. Currently we are using C++17 and GCC 9.3 for Linux and MinGW builds, so we can't use the If you wanted, maybe you could convert our mathematical constants to use the same names as those in EDIT: The constants should probably be in a new |
I'm aware that we don't have C++20 ready yet. I made the suggested changes (and more) in advance under the assumption that this PR was now dependent on #7554, based off of your suggestion. If this is not the case I can change it back, I'm good with whatever. My original intention with this PR was small in scope; I just wanted to clean up |
Ah gotcha. Sorry for the miscommunication. The C++20 support could happen tomorrow if people could review the PR, but upgrading our MinGW compiler and dependencies will be tricky and take some time. I think the |
If I understand @messmerd correctly, I agree with him. We should wait for C++20, remove |
Just to clarify, there are several useful constants in On that note, I noticed The current plan is to wait for #7554 before I make further changes. Input is welcome in the meantime! |
#7554 is here, so you can try and make the switch to the numbers header @rubiefawn (we have partial C++20 support, but I think we should have the numbers header at least).
It's up to you really (or anyone else that wants to give it a go). I personally think it could go multiple ways with no apparent downside. |
@sakertooth Nope, like most C++20 features, we're waiting for GCC 10. See: https://en.cppreference.com/w/cpp/compiler_support/20 |
Hard to classify it as an upgrade then, but I guess it's a step in the right direction.. |
I'm using both class type NTTP and designated initializers in the pin connector now, so it's not nothing. Once I'm done with the pin connector, I'd like to upgrade to GCC 11 on Linux and MinGW 13 for the cross-compiled Windows builds. Then we'll have nearly all C++20 features including |
This is the second time I've gotten duplicated commit history after pushing. Not sure if GitHub just doesn't like rebase or if it's a skill issue (likely the latter). How do I avoid this in the future? |
Don't worry, we do squash on merge. |
Wait, seems like lots of unnecessary diffs (from previously merged prs) |
Moves the four constants in panning_constants.h into panning.h, then removes panning.h.
dff4d78
to
0794170
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts which came across when I looked at the diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Untested but style and diff looks ok.
What else does this need before it can be merged? |
Some testing to check for regressions? |
lmms_constants.h
has several common constants such asPI
andE
, with variants of each forfloat
,double
, andlong double
. Many of these are currently unused in the repo but are of potential use. This change replacesLD_PI
,D_PI
, andF_PI
withlmms::numbers::pi
, and so on, in the style of C++20's<numbers>
.Currently, the constants are set using literal values, but once C++20 is fully ready these can be changed to their
std::numbers::*
equivalents instead.