From patchwork Thu May 25 23:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 70101 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8659138432D8 for ; Thu, 25 May 2023 23:18:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8659138432D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685056684; bh=5L7Yt6Si8DMgz+1lz8rTs6qhywdbOpMl1A1TpUv+blA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kkz2ftuI4PQq8z1ZMuLV5Ol7wJm6s4QnQw/Kb8tDQlYJ/iFL+eOPuQ2i8z4k9pWlb sMTWdwSnq+rSnORDIuaV6PXwbJGu70xZvagfIb3nJ8posPPwzB1YSumz74LOlKDyxR 8x/ZTZKqBF0iUJeowfysgi5JdQESWbmP9lIlgFHI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 646823858289 for ; Thu, 25 May 2023 23:17:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 646823858289 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-510-QvawiYWcOo2DuqgmZqDspg-1; Thu, 25 May 2023 19:17:29 -0400 X-MC-Unique: QvawiYWcOo2DuqgmZqDspg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32C9229AA39B; Thu, 25 May 2023 23:17:29 +0000 (UTC) Received: from localhost (unknown [10.42.28.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBFC51121314; Thu, 25 May 2023 23:17:28 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add relational operators to __gnu_test::PointerBase Date: Fri, 26 May 2023 00:17:28 +0100 Message-Id: <20230525231728.3306360-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "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(*this); }