From patchwork Tue Jan 16 14:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 188556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp356848dye; Tue, 16 Jan 2024 08:07:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNifUss/Sih2ICRcTAH4rJ8KXjksM34zbJn3IXTDPd3Vkq7WwE3kGT48AnqoS7i1pSKdba X-Received: by 2002:a05:622a:391:b0:429:b14a:9199 with SMTP id j17-20020a05622a039100b00429b14a9199mr10556714qtx.19.1705421235554; Tue, 16 Jan 2024 08:07:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705421235; cv=pass; d=google.com; s=arc-20160816; b=zYTPgmuV2FS3HsUcc0WSG9nLqWB2s9mOshsOxydJdzRMXHvyZy15Vh2E8HVij9frwg 3z6q4BywRfyeaFnSBL3j1eSMD24HJZOZcE2AIQiWFnd259DUcK9Mnm531X4YGGZnYyYj +fUJc55MmSf/PgNnSm2PraD14AtY1KqhyyGnnZL8GasH0qp6mh9YmgMAl5rT3cTvBIg2 i+I9tJ3SYInWVV3j7JbDe33hKK0tIbb7dAkPobc03CFWB1wTy6S/ZMH5jtpT9PkKniOV +TtSd+VszClOOMxEaby0nxbvWfzKNV4vo724AWgD12gmL4Z2Ua8HDqwc3WWzog5TQA8y M97A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=4jHnvK4sGhm9MxCHs64FKz+DE+XCBzGHbFDd5T95vTU=; fh=EVSvWd94bH3+6DLHxQIQnUkCnGLOu/mRCJOpcO366zA=; b=x5+zihgep01sTzZrVWgtv4DCZB4WQk5rjx9QD4oSW1bO+JrHpQC4IxXiUUWQdHChQu wqegs7cSXCmsQGcrvXwk5k7IwyKx0OAK8BvVjlE7Bf9A/bHthe2n9O4KDGRehy0CaeYw JJQC3X6Sg/PJdCK3alM1C8VK5owEFGi9O3tKjEc1dwLNS0sCwUaGKubPbXU3EmV5/taB jD08ZcKWCjinBDJ9KLQmUlCllTTSHyV9t0snefM5hHpxlbyKgP7ab6NhtyF1xHUL5Huh nLVj0wVw1i+xhqt2XCV9eEmZJTD1cRhjAz+/PElKPj+UOnSAVfvdTqpZq6rr7sVJakeR dL1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Da3KJaWe; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hf25-20020a05622a609900b00429c9669e43si9376586qtb.755.2024.01.16.08.07.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:07:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Da3KJaWe; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B987C3857C55 for ; Tue, 16 Jan 2024 14:39:36 +0000 (GMT) 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 737993858409 for ; Tue, 16 Jan 2024 14:38:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 737993858409 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 737993858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705415931; cv=none; b=uM0ZNBLBlxXkYkBXJo+HPHEuV+X46vxFPqUJIGxCnx61uk6HRocBgxQK8mzQu2h1FQGg44jTxdvOkxFxkkwcIEvZNNIjc0/0n/644SnTS17sZmcRoQY6FZPhjV2Y+TCVRR1BREsr62D+lh9oR6OlUWuMPxZudrIUCavvTbI0+Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705415931; c=relaxed/simple; bh=hqKlmC+b8DWA0jhVPq0x5yNNNazYuWwZK9Idh1fDZTs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aTtxD2oY8LJu09Abtyg9+Af63YPhcb5cLsLLj7cJ05CxZTro1B63PGmtgJefV8mbbBEPFwooRk41I0tccC/alNVWwWiBj34McjURN1XXlTR83t4mTpKBHg3nSRUYjGCrMvaZckpBCBBSmjJgRGWX7Hr2CQ7d/aWsxDGYir/gkvk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705415929; 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; bh=4jHnvK4sGhm9MxCHs64FKz+DE+XCBzGHbFDd5T95vTU=; b=Da3KJaWexFZ3xMhVdmqFtuYXLDRGWzOiLyfh8htW/WmF+MttrL7SGVhr/cIjiMSkpjghcp fok2hAm4K5R91TPl/d+DX0sqsDlC8yL7AkMiERDQIOTgA30xQoinsa6nu1O+DLse8kODFS sTL0PE0ufMyG0YBJexC2NMKwsgy2psQ= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-nj4xtlYvNByzYvI0p651Bw-1; Tue, 16 Jan 2024 09:38:48 -0500 X-MC-Unique: nj4xtlYvNByzYvI0p651Bw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67ef8bbfe89so213917796d6.0 for ; Tue, 16 Jan 2024 06:38:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705415926; x=1706020726; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4jHnvK4sGhm9MxCHs64FKz+DE+XCBzGHbFDd5T95vTU=; b=MbYyfsQdi/47O1vNkjoKMKmIHgXeQnjItCznDhit04n4mADy5RdsKpqdTUv912b6Jo aD/xcLBtSaosyfCGMS6F51w3U7uGMKYF6DQFjT/5UKYpsLJ2CI4te3WxFoc7DUGSCTrW LZSfWuOhSYXLckMNEG03exjeP9944I5iz+Ayl5ij4DJvnPexAw1aCVVjaSNdICGv4UoW qQlyKOrG93UbPsrT558VK9hpeHgj20aK8fbUi0z+vFa8Jge7p2czkEuQQKlBcyG8C7sf fud75e6W39hQSes2Q/wQIKM50ersFx6YzviS9nJQdgDr+prl0wKRHEWdnd9US0B1SwUX bY5Q== X-Gm-Message-State: AOJu0YygAJ0TscM7ZIaoAbRPQ2Uv9pyUT7USFhzCTUN6TstFp2dGoD76 t6QvswvrzjFKDSJ3qvD99ogBIQ0pyQ5y1xpZ+GeMmIlPw0JW+V4LdwtRdD0GiUtq50QtsqH5GRn URcJW7GsBZULAjJQGeKmDhMf2RhehuRJhIC2bT7q68TJY2PBcc17xL98o0xKsq85CY1mGe4ejdf OmNF/vddI= X-Received: by 2002:ad4:5ae9:0:b0:681:42e1:f7ee with SMTP id c9-20020ad45ae9000000b0068142e1f7eemr8757169qvh.27.1705415926321; Tue, 16 Jan 2024 06:38:46 -0800 (PST) X-Received: by 2002:ad4:5ae9:0:b0:681:42e1:f7ee with SMTP id c9-20020ad45ae9000000b0068142e1f7eemr8757151qvh.27.1705415925887; Tue, 16 Jan 2024 06:38:45 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id x19-20020ad44593000000b0067f678747ffsm4247301qvu.50.2024.01.16.06.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 06:38:45 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH] libstdc++: Implement P2540R1 change to views::cartesian_product() Date: Tue, 16 Jan 2024 09:38:18 -0500 Message-ID: <20240116143818.3336042-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.334.gd4dbce1db5 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.8 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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788262455488944505 X-GMAIL-MSGID: 1788263777629734981 Tested on x86_64-pc-linux-gnu, does this look OK for trunk/13? -- >8 -- This paper changes the identity element of views::cartesian_product to be a single empty tuple instead of an empty range. libstdc++-v3/ChangeLog: * include/std/ranges (views::_CartesianProduct::operator()): Adjust identity case as per P2540R1. * testsuite/std/ranges/cartesian_product/1.cc (test01): Adjust expected result of the identity case. --- libstdc++-v3/include/std/ranges | 2 +- libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 3135e6f0c08..7ef835f486a 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -8748,7 +8748,7 @@ namespace views::__adaptor operator() [[nodiscard]] (_Ts&&... __ts) const { if constexpr (sizeof...(_Ts) == 0) - return views::empty>; + return views::single(tuple{}); else return cartesian_product_view...>(std::forward<_Ts>(__ts)...); } diff --git a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc index f69f965c0ce..7281cd8a2f4 100644 --- a/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/cartesian_product/1.cc @@ -24,9 +24,9 @@ test01() int w[] = {9}; auto v0 = views::cartesian_product(); - VERIFY( ranges::end(v0) - ranges::begin(v0) == 0 ); - VERIFY( ranges::size(v0) == 0 ); - VERIFY( ranges::empty(v0) ); + VERIFY( ranges::end(v0) - ranges::begin(v0) == 1 ); + VERIFY( ranges::size(v0) == 1 ); + VERIFY( !ranges::empty(v0) ); auto v1 = views::cartesian_product(x); VERIFY( ranges::end(v1) - ranges::begin(v1) == 3 );