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
Implements issue 1491 (check for unique keys) #1541
Conversation
Hmm. I don't have an issue with this at all, but the more methods like this we gather, the more we should think about fixing it systemically by having the ability to index the fields or do multiple in one pass. |
@jkeiser We do not have to merge this, we never got a request of this type... but I only implemented it as a precaution, and a proof of concept. We certainly do not have to merge it for release 1.0. There would be other ways to handle this...
auto [value1, value2, value3] = object.get("key1", "key2", "key3"); It would always fully scan the object, and might check for duplicates as it does so. That could possibly be quite performant.
auto x = object["x"];
auto y = object["y"]; // an error here would happen Neither of these alternatives is super pleasant. |
I could imagine the single-pass matcher working, especially if each of them returns a |
I am happy to let this PR sit for a while longer. |
I do not like this PR after all. Closing. |
Some users may want to check that the keys are unique. For those users, we may provide
find_unique_field
. It works likefind_unordered_field
but scans keys in a loop to check for uniqueness. We hope that users would not rely on it within performance critical code since it is potentially quite expensive. However, it is nice feature to have around.Fixes #1491