From patchwork Tue Mar 3 16:30:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1248496 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-520544-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=LncPVx9e; 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=S6Or4ixg; 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 48X2ZX1BNqz9sPg for ; Wed, 4 Mar 2020 03:31:14 +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=fnvghIbfNUeIqLGTSroE+85SwZ0daOUo6gbACa+TtNZQDEJCpq5qa I9DMn7cJVMHSwXIIdCPY7YydGOem2E/f2DGE44nBqPLY0H8qfsxDxXYkYw3JVCYE CFcIFqJd7qbhI+T92vdQG8kl7zkC742Sh5htmiV1cKTOSiJb8S7A5A= 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=7vLgnNezQwzjfCYZf2xF18DVMoI=; b=LncPVx9ec3Br0Q+0ISEjtAhRwf7u +VurBJ+JvVbrriHFIH7Y7LBAtAk5wX2/Xyzl++ouHVhmZlo3znugRA11XgzqhY07 yao0XKMHlzn5mbOw/ag3vRQE6TZm8HJmEEKWSDa5ijZT6MaahH8rx7h8TuCysBmQ +l8ryzDw535Muv8= Received: (qmail 102574 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 102539 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=2313, sk:counted X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Mar 2020 16:30:57 +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=LunQfBAiNT66yp9X8bEI9Y6o1Lm0oBdvc0DWLO+kTXs=; b=S6Or4ixgVgtPeYLf9ccz4iKlF4l8y58R5OuG27heb8eQjiste7xIJeJ9g6xOgedj6+B0rw +YrTDv4eKbyq8OObtnWvTSighm94cXhbtoxzpVyAgMHnWatn1Z1mnSMTYSCj/yjU5uqDtJ p6n6PuQ9E6WYMVXzOYTDB6HAGmEyOto= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210--dM2NdZwMnG3NwS3VKnidg-1; Tue, 03 Mar 2020 11:30:54 -0500 Received: by mail-qt1-f199.google.com with SMTP id f25so2542294qtp.12 for ; Tue, 03 Mar 2020 08:30:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 08:30:52 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH 2/4] libstdc++: Add a move-only testsuite iterator type Date: Tue, 3 Mar 2020 11:30:41 -0500 Message-Id: <20200303163043.2182013-2-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 move-only testsuite iterator type to , which will be used in the tests that verify LWG 3355 and has already seen a need in the tests for LWG 3389 and 3390. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_iterators.h (input_iterator_wrapper_nocopy): New testsuite iterator. * testsuite/24_iterators/counted_iterator/lwg3389.cc: Use it. * testsuite/24_iterators/move_iterator/lwg3390.cc: Likewise. --- .../24_iterators/counted_iterator/lwg3389.cc | 35 ++----------------- .../24_iterators/move_iterator/lwg3390.cc | 35 ++----------------- .../testsuite/util/testsuite_iterators.h | 28 +++++++++++++++ 3 files changed, 32 insertions(+), 66 deletions(-) diff --git a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc index cf74fd47bec..8b9bf53f6c5 100644 --- a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc +++ b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc @@ -23,44 +23,13 @@ #include using __gnu_test::test_range; -using __gnu_test::input_iterator_wrapper; - -template -struct move_only_wrapper : input_iterator_wrapper -{ - using input_iterator_wrapper::input_iterator_wrapper; - - move_only_wrapper() - : input_iterator_wrapper(nullptr, nullptr) - { } - - move_only_wrapper(const move_only_wrapper&) = delete; - move_only_wrapper& - operator=(const move_only_wrapper&) = delete; - - move_only_wrapper(move_only_wrapper&&) = default; - move_only_wrapper& - operator=(move_only_wrapper&&) = default; - - using input_iterator_wrapper::operator++; - - move_only_wrapper& - operator++() - { - input_iterator_wrapper::operator++(); - return *this; - } -}; - -static_assert(std::input_iterator>); -static_assert(!std::forward_iterator>); -static_assert(!std::copyable>); +using __gnu_test::input_iterator_wrapper_nocopy; // LWG 3389 void test01() { int x[] = {1,2,3,4}; - test_range rx(x); + test_range rx(x); auto it = std::counted_iterator(rx.begin(), 2); } diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc index 1df7caccece..7e9f4a0d0cc 100644 --- a/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc +++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc @@ -23,44 +23,13 @@ #include using __gnu_test::test_range; -using __gnu_test::input_iterator_wrapper; - -template -struct move_only_wrapper : input_iterator_wrapper -{ - using input_iterator_wrapper::input_iterator_wrapper; - - move_only_wrapper() - : input_iterator_wrapper(nullptr, nullptr) - { } - - move_only_wrapper(const move_only_wrapper&) = delete; - move_only_wrapper& - operator=(const move_only_wrapper&) = delete; - - move_only_wrapper(move_only_wrapper&&) = default; - move_only_wrapper& - operator=(move_only_wrapper&&) = default; - - using input_iterator_wrapper::operator++; - - move_only_wrapper& - operator++() - { - input_iterator_wrapper::operator++(); - return *this; - } -}; - -static_assert(std::input_iterator>); -static_assert(!std::forward_iterator>); -static_assert(!std::copyable>); +using __gnu_test::input_iterator_wrapper_nocopy; // LWG 3390 void test01() { int x[] = {1,2,3,4}; - test_range rx(x); + test_range rx(x); auto it = std::make_move_iterator(rx.begin()); } diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 417dff23c50..e47b2b03e40 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -674,6 +674,34 @@ namespace __gnu_test { return iter -= n; } }; + // A move-only input iterator type. + template + struct input_iterator_wrapper_nocopy : input_iterator_wrapper + { + using input_iterator_wrapper::input_iterator_wrapper; + + input_iterator_wrapper_nocopy() + : input_iterator_wrapper(nullptr, nullptr) + { } + + input_iterator_wrapper_nocopy(const input_iterator_wrapper_nocopy&) = delete; + input_iterator_wrapper_nocopy& + operator=(const input_iterator_wrapper_nocopy&) = delete; + + input_iterator_wrapper_nocopy(input_iterator_wrapper_nocopy&&) = default; + input_iterator_wrapper_nocopy& + operator=(input_iterator_wrapper_nocopy&&) = default; + + using input_iterator_wrapper::operator++; + + input_iterator_wrapper_nocopy& + operator++() + { + input_iterator_wrapper::operator++(); + return *this; + } + }; + // A type meeting the minimum std::range requirements template class Iter> class test_range