public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Add relational operators to __gnu_test::PointerBase
@ 2023-05-25 23:17 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-05-25 23:17 UTC (permalink / raw)
  To: libstdc++, gcc-patches

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(+)

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); }
 
-- 
2.40.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-25 23:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 23:17 [committed] libstdc++: Add relational operators to __gnu_test::PointerBase Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).