-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Enable string_view keys in operator[] by updating is_usable_as_basic_json_key_type (#3912) #4958
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
|
As you can see from the godbolt link in the original issue, the issue isn't that The thing that should really be updated is You can update the test code like this to see the missing piece. |
|
@gregmarr My idea is to add specific |
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @khloodelhossiny |
Okay, that's not what your PR description says, so it wasn't clear that you knew that. I'd be worried about the compiler potentially having a problem selecting between |
|
I think a cleaner approach would be indeed to fix |
Thanks a lot for the explanation. I see your point, and I’ll update the code to follow that approach. |
Thanks for the feedback! Yes, that makes sense — I will update the code. |
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @khloodelhossiny |
c6ca564 to
d31d6fa
Compare
nlohmann
left a comment
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.
Please resolve the conflicts.
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @khloodelhossiny |
1 similar comment
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. @khloodelhossiny |
28ed925 to
002c9a2
Compare
|
I was hoping for something that didn't have to name Another possibility that seems to work and doesn't require any changes to the library is to make your type comparable to It could be a bit more generic, but that might be dangerous in the rest of the program: |
I got your point — I understand that you want the library to fully support I tried to handle that case, but I think for now it might make sense to let users define their own comparison operators if they have custom types. |
|
@gregmarr
I tried to fix them several times, but after I push new changes, other errors appear. I believe most of them are related to clang-format. My current steps are:
If I’m missing any step, please let me know — I’m starting to get a bit disappointed :( At this point, I almost believe that even if I push the develop branch, it will still fail the same checks :) |
|
@nlohmann will have to help you with the checks.
IMO, the library supports |
|
002c9a2 to
1d8ca15
Compare
Got it, thank you so much for the clarification and guidance! |
|
@nlohmann Many thanks to you! |
cdc758c to
7b72cc3
Compare
Signed-off-by: khloodelhossiny <[email protected]>
7b72cc3 to
6d97514
Compare
This pull request adds std::string_view support for operator[] to improve usability with modern C++ (C++17 and later). The behavior now matches the existing std::string overloads. Additionally, the exception messages were updated for consistency when operator[] is used with non-object types and a string_view key.
This change addresses and fixes issue #3912.
make amalgamate.Read the Contribution Guidelines for detailed information.