Enable string_view keys in operator[] by updating is_usable_as_basic_json_key_type (#3912)#4958
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.
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
|
Hi @nlohmann , I've resolved the conflicts and updated the branch. All CI checks should be green now. Let me know if there's anything else needed! |
|
This pull request has been marked as stale because it has had no activity for 30 days. While we won’t close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions! |
|
Still relevant. @nlohmann anything still needed here? |
|
Thanks a lot! |
My pleasure! Happy this was useful. |
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.