[libcxx-commits] [PATCH] D115766: [libc++] [test] Simplify (sized_)sentinel_wrapper; use it in more places.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 14 16:36:10 PST 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, var-const, libc++, jloser.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

This is the latest installment in my series "Get rid of bogus `operator==` overloads that individual test files provide, for types they don't own."

Step 1 here is `test_iterators.h`: Ensure that `sentinel_wrapper<It>` is always valid and models `sentinel_for<It>` — even when `It` is an input iterator that's not equality-comparable with itself. This also brings the code style of `sentinel_wrapper` and `sized_sentinel` into line with the rest of the test iterators: use hidden-friend operators, provide an ADL `base(it)` function, and so on. As usual for test code, the simpler the better.

Step 2 is a handful of files that were using `.base()` on a sentinel. We got rid of that method in Step 1. Namely, these files were doing `foo.base().base()` where the inner `.base()` is the Standard-mandated `.base()` member of an STL type, and the outer `.base()` is the one we just removed. ADL `base(foo.base())` is even a little easier on the eyes anyway. This affects `range.take/sentinel/base.pass.cpp`, `range.take/sentinel/ctor.pass.cpp`, `range.transform/end.pass.cpp`, `range.transform/iterator/base.pass.cpp`. Drive-by assert more intermediate results in all these tests.

Step 3 is `types.h`: Use the newly empowered `sized_sentinel<It>` in `SizedForwardView` and `SizedRandomAccessView`, eliminating several bogus `operator==` declarations! This has cascading effects in `range.common.view/{begin,end}.pass.cpp` (since the sentinel type of the view has changed spelling).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115766

Files:
  libcxx/test/std/ranges/range.adaptors/range.common.view/begin.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.common.view/end.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.common.view/types.h
  libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.take/types.h
  libcxx/test/std/ranges/range.adaptors/range.transform/end.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.transform/iterator/base.pass.cpp
  libcxx/test/std/ranges/range.adaptors/range.transform/types.h
  libcxx/test/support/test_iterators.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115766.394400.patch
Type: text/x-patch
Size: 20181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211215/81998472/attachment-0001.bin>


More information about the libcxx-commits mailing list