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: 1887088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Da3KJaWe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TDs8j0CrHz1yPJ for ; Wed, 17 Jan 2024 01:39:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A57FD3857B92 for ; Tue, 16 Jan 2024 14:39:13 +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-Google-Smtp-Source: AGHT+IFSIZoT2Y2aUiUu92QmKLtuJSgZVmyaH/CksxAhInQCWN/G716kHO/o4FeJMtz+gnq0xb2hmA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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 );