-
-
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 |
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
withPi<T>
, and so on.Between a lot of plugins having their own
#define PI 3.14...
and the coding conventions stating "Global scope constants SHALL use UpperCamelCase", these new template constants use upper camel case instead of upper snake case.Constants that are currently in use have not been removed for now, so this PR only touches
lmms_constants.h
. There are a few options:[[deprecated]]
to discourage new use