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: 1802876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) Authentication-Results: legolas.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=eZ/Fr2B6; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QvrLx0ynzz20ZF for ; Tue, 4 Jul 2023 02:03:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19846385772C for ; Mon, 3 Jul 2023 16:03:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19846385772C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688400215; 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=eZ/Fr2B6r7s/5FpzGvRtfwyRfjB29Jsu8+S6xrYOFHBaL0+TBjqOc64SoeQ72/KE/ lKcmdgY9hNKte2MVx1Wa9cT7DmR3EfwIiN06yrjrAHUMq+DP6RgGTpVuwaiPLyNsAK 66z3Tn+2UXIiueBzt00Q1v3AGfkwb//Cl7yCMMzg= 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-Google-Smtp-Source: APBJJlG6spe3fOzN02rzi3tymE94lxTd4F+E7N5Wy70gEf5TPSV1l2/tYZbcEboephuTmh9flFJnRmkhcLqdi64mZH0= 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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