]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add relational operators to __gnu_test::PointerBase
authorJonathan Wakely <jwakely@redhat.com>
Thu, 25 May 2023 20:17:19 +0000 (21:17 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 25 May 2023 23:14:43 +0000 (00:14 +0100)
The Cpp17Allocator requirements say that an allocator's pointer and
const_pointer types must meet the Cpp17RandomAccessIterator
requirements. That means our PointerBase helper for defining fancy
pointer types should support the full set of relational operators.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_allocator.h (PointerBase): Add
relational operators.

libstdc++-v3/testsuite/util/testsuite_allocator.h

index 9108ee4082179764d7b103d0c09e5965907ce4f7..70dacb3fdf296bf90736c7c582fe5760ce917ca7 100644 (file)
@@ -719,6 +719,15 @@ namespace __gnu_test
       friend std::ptrdiff_t operator-(PointerBase l, PointerBase r)
       { return l.value - r.value; }
 
+      friend bool operator<(PointerBase l, PointerBase r)
+      { return l.value < r.value; }
+      friend bool operator>(PointerBase l, PointerBase r)
+      { return l.value > r.value; }
+      friend bool operator<=(PointerBase l, PointerBase r)
+      { return l.value <= r.value; }
+      friend bool operator>=(PointerBase l, PointerBase r)
+      { return l.value >= r.value; }
+
       Derived&
       derived() { return static_cast<Derived&>(*this); }