From patchwork Tue Jul 13 19:05:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1504770 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VXrnpjeF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPVVw06jTz9sX1 for ; Wed, 14 Jul 2021 05:07:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1911396E861 for ; Tue, 13 Jul 2021 19:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1911396E861 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1626203219; bh=Wk3/UU9p6XGyvCZSjkYLozKm84+UGFF7TRpt/pTieos=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VXrnpjeF5JGarVAAZxKes+attDCdL6y1RKC8l3x/6swyLrov/CxsO32b0lVJLkQCQ qkI60mvH2QZp4oNjdlK/rLyG2H73fXS1fnzGBAefnfVn7FDLO6Nu2TpC2OtVHSWGU+ G0Ci4Kn1vEKvCPlvWUwXI6E4jZeffvyHocwZ5p/M= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7672B396E83B for ; Tue, 13 Jul 2021 19:05:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7672B396E83B 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-121-vbKM8kBnM-CbhyyC3DJiHg-1; Tue, 13 Jul 2021 15:05:42 -0400 X-MC-Unique: vbKM8kBnM-CbhyyC3DJiHg-1 Received: by mail-qt1-f199.google.com with SMTP id d11-20020ac851cb0000b02902536d2bea0fso8457169qtn.19 for ; Tue, 13 Jul 2021 12:05:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Wk3/UU9p6XGyvCZSjkYLozKm84+UGFF7TRpt/pTieos=; b=I+lHo/kmMH6yJPr2HPe24TKmND0yWKKJpqPqaAKKaZqcZbrVVZUaJHhqRLOpNrJKeR o9x55G40AJ7FS5aWAH2WJNqsfW4oy3nhB1I2jgSeOsYLwjDudX1yxn3nN6fFFJe2LmEb hsSFi72P2ljuzGqc3iH3fKO9hhX0C2FCMaQsQkS4vI8UNWfS8wEa905mqQFcWp8MfMGJ MHT+u/pqHKV/eqfeVWFVuMDuFTKsavRRe+hztPi0b3wH/PWSyIXFKEQaQ74tiP9kqoBU O0fsClWwxSPVpHkrj7iy4SMANEpQgw8a0y6UpmkQJIXzhkxF16jzUPaLX991FyPMEC/1 kofw== X-Gm-Message-State: AOAM530X7sxOL36fM3CeVqM1R6lC7hMfprn7msdRNKOnqFXeLzUKhsRM yrQcuzZkYv2fticVXW4oO0hvAZb2HY7/XS/2dXX32w2y0xfkbbEnNrkJ55vTdLFE4ke4KtEuGRx XH1kdaaJgy3BD6GEYwMVlBi4R90n6W0q9EfALtpUa+AgzebHeD1j/EKZ1NHN9I2U/U20= X-Received: by 2002:ad4:5144:: with SMTP id g4mr6395619qvq.3.1626203141527; Tue, 13 Jul 2021 12:05:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfHr/X9mf+o7M6MpoAUh4aVtnCh6To5R373Q2XvcB+Hrp/E/IYgUnyNvrXWqG5ZMXoLVTgtg== X-Received: by 2002:ad4:5144:: with SMTP id g4mr6395583qvq.3.1626203141183; Tue, 13 Jul 2021 12:05:41 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id d200sm4804007qke.95.2021.07.13.12.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 12:05:40 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Give split_view::_Sentinel a default ctor [PR101214] Date: Tue, 13 Jul 2021 15:05:37 -0400 Message-Id: <20210713190537.658783-1-ppalka@redhat.com> X-Mailer: git-send-email 2.32.0.170.gd486ca60a5 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-16.2 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This gives the new split_view's sentinel type a defaulted default constructor, something which was overlooked in r12-1665. This patch also fixes a couple of other issues with the new split_view as reported in the PR. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? PR libstdc++/101214 libstdc++-v3/ChangeLog: * include/std/ranges (split_view::split_view): Use std::move. (split_view::_Iterator::_Iterator): Remove redundant default_initializable constraint. (split_view::_Sentinel::_Sentinel): Declare. * testsuite/std/ranges/adaptors/split.cc (test02): New test. --- libstdc++-v3/include/std/ranges | 6 ++++-- libstdc++-v3/testsuite/std/ranges/adaptors/split.cc | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index f552caa9d5b..df74ac9dc19 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -3306,7 +3306,7 @@ namespace views::__adaptor && constructible_from<_Pattern, single_view>> constexpr split_view(_Range&& __r, range_value_t<_Range> __e) - : _M_pattern(views::single(__e)), + : _M_pattern(views::single(std::move(__e))), _M_base(views::all(std::forward<_Range>(__r))) { } @@ -3364,7 +3364,7 @@ namespace views::__adaptor using value_type = subrange>; using difference_type = range_difference_t<_Vp>; - _Iterator() requires default_initializable> = default; + _Iterator() = default; constexpr _Iterator(split_view* __parent, @@ -3429,6 +3429,8 @@ namespace views::__adaptor { return __x._M_cur == _M_end && !__x._M_trailing_empty; } public: + _Sentinel() = default; + constexpr explicit _Sentinel(split_view* __parent) : _M_end(ranges::end(__parent->_M_base)) diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc index 02c6073a503..b4e01fea6e4 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc @@ -46,6 +46,16 @@ test01() VERIFY( ranges::equal(ints, (int[]){1,2,3,4}) ); } +void +test02() +{ + // PR libstdc++/101214 + auto v = views::iota(0) | views::take(5) | views::split(0); + static_assert(!ranges::common_range); + static_assert(std::default_initializable); + static_assert(std::sentinel_for); +} + // The following testcases are adapted from lazy_split.cc. namespace from_lazy_split_cc { @@ -189,6 +199,7 @@ int main() { test01(); + test02(); from_lazy_split_cc::test01(); from_lazy_split_cc::test02();