[libcxx-commits] [PATCH] D150831: [libc++] Implement ranges::ends_with

Zijun Zhao via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 31 18:43:33 PDT 2023


ZijunZhao added inline comments.


================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp:45
+static_assert(!HasEndsWithIt<int*, int*, int*, SentinelForNotSemiregular>);
+static_assert(!HasEndsWithIt<int*, int*, int*, SentinelForNotWeaklyEqualityComparableWith>);
+
----------------
philnik wrote:
> Let's also add tests for AlmostInputRanges which a valid sized sentinel.
I have some questions. 
1. I find nothing about `AlmostInputRanges` but `AlmostInputIterator` is in the `common_iterators.h`. Is it what we need? 
2. And how do we know we need to add it?


================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp:227-247
+  { // check that std::invoke is used
+    struct S {
+      int i;
+
+      constexpr S identity() { return *this; }
+
+      constexpr bool compare(const S& s) { return i == s.i; }
----------------
philnik wrote:
> Please use the `libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp` test instead.
Does it mean I need to change array in that kind

```
std::array in  = {Bar{Foo{1}}, Bar{Foo{2}}, Bar{Foo{3}}};
std::array in2 = {Bar{Foo{4}}, Bar{Foo{5}}, Bar{Foo{6}}};
```


================
Comment at: libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp:80
   test(std::ranges::starts_with, in, in2, eq, proj1, proj2);
-  // test(std::ranges::ends_with, in, in2, eq, proj1, proj2);
 #endif
----------------
philnik wrote:
> Please update all the `robust_against_*` tests!
Files like `ranges_robust_against_nonbool_predicates.pass.cpp`, they don't have/comment out any `ends_with` tests but they have some tests involve `mismatch`, `all_of` and so on. So I need to add `ends_with` tests right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150831



More information about the libcxx-commits mailing list