From: Jonathan Wakely Date: Thu, 25 May 2023 20:17:19 +0000 (+0100) Subject: libstdc++: Add relational operators to __gnu_test::PointerBase X-Git-Tag: basepoints/gcc-15~8890 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d2fa90a41567670d2dbd4918d19d21d9bec4a8f;p=thirdparty%2Fgcc.git libstdc++: Add relational operators to __gnu_test::PointerBase 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. --- diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h index 9108ee408217..70dacb3fdf29 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(*this); }