Skip to content
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

Core: Support c++20 compilation #89660

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Mar 18, 2024

Adds a new cpp_standard experimental variable to SCons, to allow the user to choose which C++ standard to compile with. The choices are "17" and "20", defaulting to 17. In addition, this makes changes across the repo to allow compilation of c++20 to be possible in the first place, which primarily comes down to more operators to prevent ambiguous conversions. Currently, a c++20 build successfully compiles (with werror=no).

Submitted as a draft, as while the equality operators are accounted for, there's still the ordering operators. Inequality operators could be handled with a wrapper, but ordering operators will be a bit more involved than that; ideally the <=> operator will be used, so long as parity with the secondary operators is kept between 17 & 20. There's also the matter of making sure the other warnings are accounted for, which are largely secondary but still important so long as they don't negatively impact c++17 (which will remain the repo "default").

EDIT: Added "support" for c++23 as well, albeit to a much lesser extent because its currently experimental.

@@ -835,17 +835,6 @@ bool Variant::operator==(const Variant &p_variant) const {
return hash_compare(p_variant);
}

bool Variant::operator!=(const Variant &p_variant) const {
// Don't use `!hash_compare(p_variant)` given it makes use of OP_EQUAL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note matters, so I don't think this is a valid change, is not having an explicit != operator required for C++20? If so that's a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a requirement, no; if need be, this can be the exception to the implicit conversion. With that said, all the existing tests pass, and I don't think there's any Variant operation where x != y and !(x == y) produce different values. Still worth looking into for verification, but I'm skeptical of how much weight this note has.

@Repiteo Repiteo force-pushed the core/c++20-support branch 3 times, most recently from 2b315bd to eea4fcd Compare March 28, 2024 18:46
@Repiteo Repiteo force-pushed the core/c++20-support branch 4 times, most recently from 655a1da to 4e4d1f5 Compare April 8, 2024 15:47
@Repiteo Repiteo force-pushed the core/c++20-support branch 4 times, most recently from f3044b6 to 1b1499a Compare April 25, 2024 17:07
• Technically c++23 as well, albeit to a *much* lesser extent because it's not officially released
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants