-
Notifications
You must be signed in to change notification settings - Fork 215
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
Switch to C++20 #976
Switch to C++20 #976
Conversation
This is necessary to pick up a new version of Async++, which is required for use with C++20.
Because we seem to be running out of memory and crashing in C++20 builds.
I'm marking this ready to review. My only small reservation is that it still uses (by necessity) a pre-release vcpkg repo. I think the new version, including the fix we require, should be out by the end of the month. |
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.
@kring looks good to me! I just had one comment that I wanted to run by you before merging
* @param s The `std::u8string`. | ||
* @return The equivalent `std::string`. | ||
*/ | ||
static std::string toStringUtf8(const std::u8string& s); |
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.
Nitpick but, I feel it would be more informative to say toStdString
? The input and output are both UTF8, and the only thing really changing is putting it in a std::string wrapper.
static std::string toStringUtf8(const std::u8string& s); | |
static std::string toStdString(const std::u8string& s); |
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.
I think the Utf8
bit is important. It's true the function doesn't change the UTF8-ness of the string, but that's the key feature to communicate. String
was meant to imply std::string
, but maybe that's not obvious. How about toStdStringUtf8
?
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.
That's a fair point. I was thinking back to Unreal / Unity contexts where there are multiple string types, so they have functions like ToFString()
, toStlString()
, etc. But specifying std::string
is probably overkill for Native, where C++ std::string
is the norm. You can disregard this comment!
New release of vcpkg is out, which should let us move off the prerelease one used in this branch. I'll do that today. |
@kring I went ahead and switched us over to 2024.11.16. Looks like I haven't broken CI, so I'll merge now. Thanks! 😄 |
The main motivation here is support for the upcoming Unreal Engine 5.5. It uses the GSL library, as cesium-native does, but it's a modified (broken) version of it, so we can't use UE's version in cesium-native. Using our own copy creates conflicts with Unreal's. So one possible solution is to switch to C++20, change all the
gsl::span
tostd::span
, and drop the dependency on GSL. This PR is the first step in that.Some notes:
TestPropertyTableView.cpp
for C++20 RelWithDebInfo on Ubuntu 22.04 uses a ton of memory, crashing the GitHub Actions runner. We should be able to fix this by moving away fromstd::variant
, as we've done in Unreal and Unity, now that we're on C++20. But for now I've just added a build step to increase available swap space so that the build can complete successfully.u8string
method ofstd::filesystem::path
returning astd::u8string
instead of a regularstd::string
. This is fairly painful because we were already usingstd::string
to represent a UTF-8 string (in C++17 there was no better alternative), and there's apparently no conversion betweenu8string
andstring
. We should consider whether we should standardize onu8string
everywhere, but I'm not sure of the implications. For now I've done the simplest thing: I've added a conversion and called it where we need it.Spec
classes had a private constructor, when it should have been protected. C++17 didn't care (surprisingly!), but C++20 does. C++20 also requires that derived classes explicitly declare a public constructor if they're expected to have one.