From patchwork Mon Jul 3 16:02:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gonzalo Brito Gadeschi X-Patchwork-Id: 115425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp625551vqx; Mon, 3 Jul 2023 09:04:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEpO8g4a9G3IjMLXfxo81R0DtvJdtuFqBEql79FaDwHQrN6jsYFKOoa+ZBxLmlbElOQ3X+l X-Received: by 2002:a2e:9258:0:b0:2b6:c3b8:3a9f with SMTP id v24-20020a2e9258000000b002b6c3b83a9fmr7722456ljg.29.1688400254840; Mon, 03 Jul 2023 09:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688400254; cv=none; d=google.com; s=arc-20160816; b=Vv1ivqBWzg2tI3sBDNQ1n4rad1W/672CtwBFubXjfdWfy8KAq7PSQJr+dJ5KPQpt5F +AsXWmsmKMgzkRhxa2d9Nt9PybCLVKcMio9xq6ek3koAMEGOWXQTtjerPjLpwM2t+fs5 EzIztsNRL9xAM2uVPkSQJUUKO7OG1ZcNckOMvgLS3hKxbtqtxpy9fRSnGt/gOQFczsPr 0gRzV7IRRwtSIBGwnaCfqL+j+31r/9XdPPQ+VJIdejsQY81gWTq6NGWGJF9OO3hMulcp 1k5kUnfUWKLWMMVvyFgnOomDTlHlvOX47BY04uQzqEd8Mqv9KI3fmxy34s/swxkT+rKH rUxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=VoSywbcYuH+UAP/FyDsQHQh+ufRXmWT8vk8kvmK0ukE=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=bW+D98L8sydvGWjwqrfFJt3/0ooVUjtXOn/ZB1va9+0P2FBprJPzG+JKKNIsu2OWXl WI6DN2bBuQlZnpO0P1CezWHd9KV6V1NhaBGNfLpsmLFwCSoyzIKoO8wHvPBlrjhD+VQU 5xVWdiYwC/9gzwkReVwqAj0xcGGiILARRqmrr7Qp/oVKtkmqbpUeZTJNh34OmEXF4DqU v/cHbGVngm0qBEBRM3QH81bi3Q0Ino/5MV/qDVJctVWSuWF9ugM70H5yEaJuIRgSkWT5 0bZs5JlNlS/C3iuYalAAI8bZxEzqZXVOKqYxgETZkv0m9suZ7QhMmlVqsua80sj8N4kp S7EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j9XT751t; 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=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lx16-20020a170906af1000b0099301d21540si3554352ejb.859.2023.07.03.09.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 09:04:14 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=j9XT751t; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C9D4385734E for ; Mon, 3 Jul 2023 16:03:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C9D4385734E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688400238; bh=VoSywbcYuH+UAP/FyDsQHQh+ufRXmWT8vk8kvmK0ukE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=j9XT751t6gRugmjAHRjkh+tEuC3WDnJwUkX7bRVILBhBKz6WmnIsyujLxyarG7BLz 9gkOWP+z9WkM4XXoAbREIa0bYQ26L4Tg2p/evnQIYkg7poaAAoKCZYLpX/YxWMWQuL nbEHsIyjEE49k6dA7y+cfeZtVWL4lUqgYzrvb2FI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 92F6B3858D28; Mon, 3 Jul 2023 16:03:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92F6B3858D28 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-51d9890f368so5155016a12.2; Mon, 03 Jul 2023 09:03:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688400194; x=1690992194; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rjY8jdH/PCUWlZKln4lZxOUU229coSCNW8qPpZ7MAQ4=; b=Ck/4tmKrEnE6Jgwz/mL8dS97CIu+pizc7D0i12ueTNgnf/WvRUfMYXb0YiD3mzW+Fy noIsteojp/wFy3t8plJcYOY4zyD2W8pxYK5iQl8BRUf86PAutsn9smTQo1TUJWslH8cJ QUT1CFm6vO9Qz1lLYE4bmRPVQNv/hWwjso63f8IAh89SQZxxtmXbSwopF9wjvX3dFmtl noCmclUWkcs1HY1nCZck/9gi1sGk5tTHAwxZ4GvHT+c1+qly0aR/PETzxXLPGaj8O+Z0 H5xeoOy//Mx0JreJZozKk3KS8BuEyw4hJNVJCXzf2dfzV8AB8r5KGsCq8nevGI0OmP7I zmOw== X-Gm-Message-State: ABy/qLb4O31PnA+nLMkZtz4730S6aOQshA0m81IThfZRc3FqN+e6P8oC T77Jy6LE2gteQy6EwQu44qEOhp3nLVvGRXBc/oCiME8L/uF+pw== X-Received: by 2002:a05:6402:128d:b0:51d:f8f0:3676 with SMTP id w13-20020a056402128d00b0051df8f03676mr4910060edv.42.1688400193922; Mon, 03 Jul 2023 09:03:13 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 3 Jul 2023 18:02:57 +0200 Message-ID: Subject: [PATCH v2] libstdc++: PSTL dispatch for C++20 range random access iterators [PR110512] To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Gonzalo Brito Gadeschi via Gcc-patches From: Gonzalo Brito Gadeschi Reply-To: Gonzalo Brito Gadeschi Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770415985711892844?= X-GMAIL-MSGID: =?utf-8?q?1770415985711892844?= libstdc++: Recognize C++ random access iterators as random access in PSTL [PR110432] The check for random access iterators in the PSTL only checks whether the iterator inherits from the random_access_iterator_tag, failing to recognize random access iterators originating in C++20 ranges and views. This patch extends the check to also recognize types that model the C++20 random_access_iterator concept as providing random access. This is allowed by C++23's P2408, which is safe to backport to C++20, because any application that would break already exhibits undefined behavior due to precondition violation. libstdc++-v3/ChangeLog: PR libstdc++/110512 * include/pstl/execution_impl.h Recognize C++20 random access iterators as random access. Bootstrapping and testing * Tested with x86_64-pc-linux-gnu. --- libstdc++-v3/include/pstl/execution_impl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) +>; template using __are_random_access_iterators = __are_iterators_of; diff --git a/libstdc++-v3/include/pstl/execution_impl.h b/libstdc++-v3/include/pstl/execution_impl.h index 64f6cc4357a..c17da29141e 100644 --- a/libstdc++-v3/include/pstl/execution_impl.h +++ b/libstdc++-v3/include/pstl/execution_impl.h @@ -22,7 +22,15 @@ namespace __internal template using __are_iterators_of = std::conjunction< - std::is_base_of<_IteratorTag, typename std::iterator_traits>::iterator_category>...>; +#if __cplusplus >= 202002L + std::disjunction< + std::is_base_of<_IteratorTag, typename std::iterator_traits>::iterator_category>, + std::integral_constant> + >... +#else // __cplusplus + std::is_base_of<_IteratorTag, typename std::iterator_traits>::iterator_category>... +#endif // __cplusplus