From patchwork Tue Mar 3 16:30:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1248497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-520545-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=W3+l3Mdu; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MMKWIJtM; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48X2Zk4nHfz9sPg for ; Wed, 4 Mar 2020 03:31:26 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=H9FDu5+GkNHsdgBNBqZeWFl03ZIEnvI8PbSuxF3GJB9siSOzebKmB kQ36nfiwMefxc0fF90YfHmJ3I+CKwaqOtFWyK7iWpq8JPRBGuHjlRcFWOYDkVxjI Ri1VQaD/0HglJOSjTV4tWMVIZfCef6/Y5N15UEkaEqM1hdIMY28sM8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=j0OQbUn3CwKh4JblMPxrrLpxyZ4=; b=W3+l3MduFPwv5X8ShZCGcSLdCS88 oSBUhEAgDY82lk9+z1AgRSeNK5F7DSzyJPv1q1SCCgGwdSj8pI4/MomyoWdtJLCD SIW4hnKMWB4I+Byb5ckGKlfWETKEZmeV4B1ESws0RXDcE3Lh8w9Spu+uioHp5OdD OeTWkLBuMcSrbaU= Received: (qmail 102650 invoked by alias); 3 Mar 2020 16:31:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 102542 invoked by uid 89); 3 Mar 2020 16:30:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=friend X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Mar 2020 16:30:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rne0byjPCE3fbAV31Bp6wZ1xcX48od4ni7rDFX+V+RE=; b=MMKWIJtMJYv0MPvI910TEo86rmtgn6bQSDoc97FCQTQxCX9anh5L+4iZFrRsSZSL2to3N3 wKE1su2hdo++7qrVj5+pxfkSgmvXofnLmsy3aIGL1pYXII5t02SyErRCnYfhZqN3i4Sccn TJkH+bqgu02mDe1/8rB4eiZM6Vee2so= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-134-hB1VsPOqNu6AKsPtVsmN4g-1; Tue, 03 Mar 2020 11:30:55 -0500 Received: by mail-qt1-f198.google.com with SMTP id p12so2555057qtu.6 for ; Tue, 03 Mar 2020 08:30:55 -0800 (PST) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id h24sm5412159qkk.3.2020.03.03.08.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 08:30:54 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH 3/4] libstdc++: Add a test range type that has a sized sentinel Date: Tue, 3 Mar 2020 11:30:42 -0500 Message-Id: <20200303163043.2182013-3-ppalka@redhat.com> In-Reply-To: <20200303163043.2182013-1-ppalka@redhat.com> References: <20200303163043.2182013-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes This adds a test range type whose end() is a sized sentinel to , which will be used in the tests that verify LWG 3355. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_iterators.h (test_range::get_iterator): Make protected instead of private. (test_sized_range_sized_sent): New. --- .../testsuite/util/testsuite_iterators.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index e47b2b03e40..756940ed092 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -735,6 +735,7 @@ namespace __gnu_test { return i.ptr - s.end; } }; + protected: auto get_iterator(T* p) { @@ -812,6 +813,37 @@ namespace __gnu_test using test_output_sized_range = test_sized_range; + // A type meeting the minimum std::sized_range requirements, and whose end() + // returns a size sentinel. + template class Iter> + struct test_sized_range_sized_sent : test_sized_range + { + using test_sized_range::test_sized_range; + + template + struct sentinel + { + T* end; + + friend bool operator==(const sentinel& s, const I& i) noexcept + { return s.end == i.ptr; } + + friend std::iter_difference_t + operator-(const sentinel& s, const I& i) noexcept + { return s.end - i.ptr; } + + friend std::iter_difference_t + operator-(const I& i, const sentinel& s) noexcept + { return i.ptr - s.end; } + }; + + auto end() & + { + using I = decltype(this->get_iterator(this->bounds.last)); + return sentinel{this->bounds.last}; + } + }; + // test_range and test_sized_range do not own their elements, so they model // std::ranges::borrowed_range. This file does not define specializations of // std::ranges::enable_borrowed_range, so that individual tests can decide