[libcxx-commits] [libcxx] [libc++][NFC] Centralize test for support of == and != in ranges (PR #78481)
    Will Hawkins via libcxx-commits 
    libcxx-commits at lists.llvm.org
       
    Tue Mar 12 21:18:08 PDT 2024
    
    
  
================
@@ -63,37 +64,33 @@ struct Range : TupleBufferView {
 using R                = Range<Sent>;
 using CrossComparableR = Range<CrossComparableSent>;
 
-// Test Constraint
-template <class I, class S>
-concept HasEqual = requires(const I i, const S s) { i == s; };
-
 using std::ranges::elements_view;
 using std::ranges::iterator_t;
 using std::ranges::sentinel_t;
 
-static_assert(HasEqual<iterator_t<elements_view<R, 0>>, //
-                       sentinel_t<elements_view<R, 0>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<elements_view<R, 0>>, //
+                                              sentinel_t<elements_view<R, 0>>>);
 
-static_assert(!HasEqual<iterator_t<const elements_view<R, 0>>, //
-                        sentinel_t<elements_view<R, 0>>>);
+static_assert(!weakly_equality_comparable_with<iterator_t<const elements_view<R, 0>>, //
+                                               sentinel_t<elements_view<R, 0>>>);
 
-static_assert(!HasEqual<iterator_t<elements_view<R, 0>>, //
-                        sentinel_t<const elements_view<R, 0>>>);
+static_assert(!weakly_equality_comparable_with<iterator_t<elements_view<R, 0>>, //
+                                               sentinel_t<const elements_view<R, 0>>>);
 
-static_assert(HasEqual<iterator_t<const elements_view<R, 0>>, //
-                       sentinel_t<const elements_view<R, 0>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<const elements_view<R, 0>>, //
+                                              sentinel_t<const elements_view<R, 0>>>);
 
-static_assert(HasEqual<iterator_t<elements_view<R, 0>>, //
-                       sentinel_t<elements_view<R, 0>>>);
+static_assert(weakly_equality_comparable_with<iterator_t<elements_view<R, 0>>, //
----------------
hawkinsw wrote:
I concur. It looks like there is a pattern of four (4) tests for each of `R` and `CrossComparableR` (i.e.,
| left operand | right operand |
| -- | -- |
|  type | type |
| const type | type |
|type | const type |
|const type | const type |
and there was a simple copy/paste error here. I have addressed it with the update!
Good eyes! 
https://github.com/llvm/llvm-project/pull/78481
    
    
More information about the libcxx-commits
mailing list