[libcxx-commits] [PATCH] D100587: [libc++][ranges] iterator.concept.sizedsentinel: sized_sentinel_for and disable_sized_sentinel_for.
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 15 12:31:06 PDT 2021
zoecarver marked an inline comment as done.
zoecarver added inline comments.
================
Comment at: libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.sentinel/sized_sentinel_for.compile.pass.cpp:186-190
+static_assert(check_not_sized_sentinel_for<std::unordered_map<int, int> >());
+static_assert(
+ check_not_sized_sentinel_for<std::unordered_multimap<int, int> >());
+static_assert(check_not_sized_sentinel_for<std::unordered_set<int> >());
+static_assert(check_not_sized_sentinel_for<std::unordered_multiset<int> >());
----------------
Quuxplusone wrote:
> These initially confused me, but then I got it: it's because these iterators are merely bidirectional, not random-access, so they don't support `operator-`, so they're not "sized" sentinels. I would prefer to eliminate the dependency on the associative containers and write simply e.g.
> ```
> #include "test_iterators.h"
> static_assert(std::sized_sentinel_for<random_access_iterator<int*>, random_access_iterator<int*>>);
> static_assert(!std::sized_sentinel_for<bidirectional_iterator<int*>, bidirectional_iterator<int*>>);
> ```
SGTM. Will do.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100587/new/
https://reviews.llvm.org/D100587
More information about the libcxx-commits
mailing list