[libcxx-commits] [PATCH] D112836: [libc++] Transparent unordered_foo::count() should use __count_multi.
Ruslan Arutyunyan via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 8 13:43:24 PST 2021
rarutyun added a comment.
Thanks for creating the review for this issue. To be honest when implementing this stuff I didn't realize that unique containers may return multiple results in heterogeneous case. Currently I know that because this question is very relevant to the https://wg21.link/P2363 paper.
When thinking about unordered containers we (as authors of mentioned paper) were not able to find the good example for multiple values to be returned. Thus, I believe multiple values are relevant for ordered unique containers only (as @Quuxplusone pointed out) because we don't know the order of elements within unordered container.
Consider https://godbolt.org/z/bK4WzE3ao. Even if the keys with `pair::first == 1` appear to be "in row" in the code the assertion fails. The interesting thing is if change the container in provided example to:
std::unordered_map<std::pair<int, int>, int, Hash, Eq> m = {
{{4, 1}, 1}, {{1, 3}, 3}, {{1, 4}, 4}, {{1, 2}, 5}, {{1, 2}, 2},
};
the assertion passes while `count` method should return `4`.
Overall, I think I agree with the judgement of @Quuxplusone about impossibility to implement due to out-of-order elements within container (or I don't understand something).
Thanks again to keeping me in the loop because, first, it's interesting problem, second, this review might help with some answers for P2363 <https://reviews.llvm.org/P2363>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112836/new/
https://reviews.llvm.org/D112836
More information about the libcxx-commits
mailing list