[libcxx-commits] [libcxx] [libc++][NFC] Centralize test for support of == and != in ranges (PR #78481)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 27 15:09:16 PDT 2024


================
@@ -70,37 +70,33 @@ struct LessThan3 {
   constexpr bool operator()(int i) const { return i < 3; }
 };
 
-// Test Constraint
-template <class I, class S>
-concept HasEqual = requires(const I i, const S s) { i == s; };
-
 using std::ranges::iterator_t;
 using std::ranges::sentinel_t;
 using std::ranges::take_while_view;
 
-static_assert(HasEqual<iterator_t<take_while_view<R, LessThan3>>, //
-                       sentinel_t<take_while_view<R, LessThan3>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<take_while_view<R, LessThan3>>, //
+                                              sentinel_t<take_while_view<R, LessThan3>>>);
 
-static_assert(!HasEqual<iterator_t<const take_while_view<R, LessThan3>>, //
-                        sentinel_t<take_while_view<R, LessThan3>>>);
+static_assert(!weakly_equality_comparable_with<iterator_t<const take_while_view<R, LessThan3>>, //
+                                               sentinel_t<take_while_view<R, LessThan3>>>);
 
-static_assert(!HasEqual<iterator_t<take_while_view<R, LessThan3>>, //
-                        sentinel_t<const take_while_view<R, LessThan3>>>);
+static_assert(!weakly_equality_comparable_with<iterator_t<take_while_view<R, LessThan3>>, //
+                                               sentinel_t<const take_while_view<R, LessThan3>>>);
 
-static_assert(HasEqual<iterator_t<const take_while_view<R, LessThan3>>, //
-                       sentinel_t<const take_while_view<R, LessThan3>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<const take_while_view<R, LessThan3>>, //
+                                              sentinel_t<const take_while_view<R, LessThan3>>>);
 
-static_assert(HasEqual<iterator_t<take_while_view<R, LessThan3>>, //
-                       sentinel_t<take_while_view<R, LessThan3>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<take_while_view<R, LessThan3>>, //
----------------
var-const wrote:

Thanks! By the way, feel free to skip putting a link to the exact commit -- there's nothing wrong with doing that, of course, but I imagine it adds extra overhead for you to post these links that can easily be avoided (I'm looking at the whole delta since the last review anyway, and I would imagine other reviewers do so as well). Just trying to save you some time/friction!

https://github.com/llvm/llvm-project/pull/78481


More information about the libcxx-commits mailing list