[committed] libstdc++: Add relational operators to __gnu_test::PointerBase

Message ID 20230525231728.3306360-1-jwakely@redhat.com
State Accepted
Headers
Series [committed] libstdc++: Add relational operators to __gnu_test::PointerBase |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonathan Wakely May 25, 2023, 11:17 p.m. UTC
  Tested x86_64-linux. Pushed to trunk.

-- >8 --

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 | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index 9108ee40821..70dacb3fdf2 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -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); }