[libcxx-commits] [PATCH] D101922: [libcxx][iterator] adds `std::ranges::advance`

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 21 10:36:16 PDT 2021


cjdb added inline comments.


================
Comment at: libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/advance.pass.cpp:40
+constexpr void check_round_trip(stride_counting_iterator<I> const& i, std::ptrdiff_t const n) {
+  assert(i.distance_traversed() <= 1);
+  assert(i.displacement() == n < 0 ? -1 : 1);
----------------
cjdb wrote:
> zoecarver wrote:
> > zoecarver wrote:
> > > When would this not be exactly one?
> > Maybe `i.distance_traversed() == 1 || n & i.distance_traversed() == 0`.
> In the case where assignment happens, which has `distance_traversed == 0`.
That's really unclear. There are only two states: 0 or 1. I can see the case for wanting an explicit `i.stride_count() == 0 || i.stride_count() == 1`, but `n & i.stride_count() == 0` is a strange way to word that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101922/new/

https://reviews.llvm.org/D101922



More information about the libcxx-commits mailing list