[libcxx-commits] [PATCH] D109668: [libc++][test] Fix iterator assertion in span.cons/deduct.pass.cpp

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 13 11:22:45 PDT 2021


jloser marked 4 inline comments as done.
jloser added inline comments.


================
Comment at: libcxx/test/std/containers/views/span.cons/deduct.pass.cpp:50
     ASSERT_SAME_TYPE(S, std::span<int, 3>);
     assert((std::equal(std::begin(arr), std::end(arr), s.begin(), s.end())));
     }
----------------
Quuxplusone wrote:
> For another, the right assertion here and throughout is actually
> ```
> assert(s.begin() == arr.begin());
> assert(s.end() == arr.end());
> ```
> That is, we should verify that the span gets the right settings for its members, in terms of the original array, //not// just that it's viewing onto //some// array with the same contents as the original.
> As a bonus, this eliminates the test's dependency on `<algorithm>`.
I like that idea, but I don't think that "just works" because of how span's iterators are `__wrap_iter` depending on `_LIBCPP_DEBUG_LEVEL`, so there won't be a `operator==` to make that valid. Example error:

```
error: invalid operands to binary expression ('int *' and 'std::span<int, 3>::iterator' (aka '__wrap_iter<int *>'))
    assert(std::begin(arr) == s.begin());
```

Is there something I'm missing to make this work regardless of whether the span's iterator type is `pointer` or `__wrap_iter<pointer>`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109668



More information about the libcxx-commits mailing list