-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Provide fallback for missing char8_t
support
#4736
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
base: develop
Are you sure you want to change the base?
Conversation
f77af2b
to
a66c329
Compare
a66c329
to
69c3fd0
Compare
@@ -443,12 +443,8 @@ inline void to_json(BasicJsonType& j, const T& t) | |||
template<typename BasicJsonType> | |||
inline void to_json(BasicJsonType& j, const std_fs::path& p) | |||
{ | |||
#ifdef JSON_HAS_CPP_20 | |||
const std::u8string s = p.u8string(); | |||
const auto& s = p.u8string(); |
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.
Removing the conditional compilation adds an unnecessary copy to those using it in C++17.
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.
Unfortunately, without this change the tests fail because BasicJsonType::is_string
no longer holds in corresponding from_json
.
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.
Testing against 201811L
seems to solve the issue. However, compilation using Clang 11.0.x starts failing again.
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.
@sergiud Oh, that's annoying. So, libc++ in Clang 11.0.x sets __cpp_lib_char8_t 201811L
but doesn't actually implement p.u8string()
returning std::u8string
until it's set to 201907L
?
That's ugly.
However, this still means that everything using C++17 has to pay for this copy unnecessarily, where they didn't before. Would the following work?
const auto& s = p.u8string();
#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
j = std::string(s.begin(), s.end());
#else
j = s; // returns std::string in C++17
#endif
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.
Yes, __cpp_lib_char8_t
version is somewhat unreliable. Therefore, instead of feature testing against a specific version for char8_t
library support a better approach is probably to provide a std::u8string
overload whenever __cpp_lib_char8_t
is defined.
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 reasonable.
69c3fd0
to
161f0de
Compare
161f0de
to
8fb2005
Compare
Would it make sense to extend the CI to run the Clang tests additionally with |
The Given GCC 14 (using libstdc++) suffers from a related issue, reproducing the setup for the latter is probably also sensible going forward. |
Yes, these jobs use the latest Clang version. Question is if it makes sense to also do this with (some/all) of the other Clang versions we use in
Not sure what additional setup is used there. We already use GCC 14 in the CI. Maybe @jelly can help? |
8fb2005
to
68a0a01
Compare
According to #4733 (comment) it's |
68a0a01
to
955d205
Compare
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @sergiud |
955d205
to
19687e7
Compare
c26c38a
to
1d11ec1
Compare
Clang 11.0.x with libc++ fails to compile tests in C++20 mode due to incomplete char8_t support in std::filesystem::path. Signed-off-by: Sergiu Deitsch <[email protected]>
1d11ec1
to
6c4cf7a
Compare
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @sergiud |
4b8310c
to
3d089b2
Compare
Clang 11.0.x with libc++ fails to compile tests in C++20 mode due to incomplete
char8_t
support instd::filesystem::path
. Use a specific library feature guard instead of performing a generic C++20 language standard check.Fixes #4733
make amalgamate
.Read the Contribution Guidelines for detailed information.