From patchwork Mon Apr 17 03:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1769437 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=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=ZS0u3U73; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q0CfD211Kz1yb4 for ; Mon, 17 Apr 2023 13:46:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42112385694D for ; Mon, 17 Apr 2023 03:46:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42112385694D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681703202; bh=5hymaym0MzHv3Y1KsFD91gEIP6a0u59aLhVPzKUoe0Y=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ZS0u3U73lAel7gECFOGMtr62ezLK/sMoqlp8GWUJFUBi891c21beN0kJz0wL5lx6N R+AMNeYjNN38WoqwPF5Wcrf7ja2POEKYDdZFMmq4dBrwwP0KiI9238GdM0SyhBmFfi oG+VPhMTNdCo6Upw6Yog9uOR/xOkBfqEFrK4wSX8= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id B06B33858CDB for ; Mon, 17 Apr 2023 03:45:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B06B33858CDB Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-ZkDgTorMPBaM45qXs-PI_w-1; Sun, 16 Apr 2023 23:45:47 -0400 X-MC-Unique: ZkDgTorMPBaM45qXs-PI_w-1 Received: by mail-qv1-f70.google.com with SMTP id qf10-20020a0562144b8a00b005e7c60f8fe0so12227948qvb.6 for ; Sun, 16 Apr 2023 20:45:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681703146; x=1684295146; 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=5hymaym0MzHv3Y1KsFD91gEIP6a0u59aLhVPzKUoe0Y=; b=YKCkroqoMWUPEvT8aQxY70ijZ/nXjk2bSdnHi2b93jcpOQTbYzrZ6206wFf221ZNEj uEfyhwHMIsG7YBoowjGS6NXWlEkGQttHkpe2o9LintesDaddEMDMD9g8jmV9+vpy2wIL 3EnZe93/zPqiBcHXXQV20EmUf0icmPG7gaUq/Ys43YoZH5QA8ErUv39FBbBzvJv9kHBt DkVtDVYmUOQUO/YnhQ5O01lv+XmYCOhI5AevgPZRaHZkf1O3xJw6sXnlzHZsb7VT2BSV Vpl5a/Qd8jdxqw+6OINJTyPDh0BFVTTUJGoEDR5z2BS03694jw42yaixVzq7AkXokytZ w/9g== X-Gm-Message-State: AAQBX9cZijuJUk2q8ybfwxyFJBy2vaK5tzmB7jBnfzDxI+PDTasPzqkq h3GOviezWgYOxqOrY+r4MaCxlLM25zQyltr9IL7qJ8NdB75jiukneiWvNgaaC7QV9XnU2ZhQdJ3 nwPZdDIzFWhvW12viZC3PgSG2O+rMkKmB0gxsXtsgnvlF0J1ufNFZrstgBSK/e96Ct/vnNZIVwP 0= X-Received: by 2002:a05:6214:509c:b0:5ef:5be2:f6d0 with SMTP id kk28-20020a056214509c00b005ef5be2f6d0mr13183685qvb.6.1681703146350; Sun, 16 Apr 2023 20:45:46 -0700 (PDT) X-Google-Smtp-Source: AKy350biefDn339wGraptndCFGl/kti6W0yNPWH4TG/oh9fDRzrqKD8/utD/Es10vzTfzS4HamtiSw== X-Received: by 2002:a05:6214:509c:b0:5ef:5be2:f6d0 with SMTP id kk28-20020a056214509c00b005ef5be2f6d0mr13183671qvb.6.1681703146052; Sun, 16 Apr 2023 20:45:46 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id bz15-20020ad44c0f000000b005ef608dc422sm1491885qvb.41.2023.04.16.20.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 20:45:45 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH] libstdc++: Adding missing feature-test macros for C++23 ranges algos Date: Sun, 16 Apr 2023 23:45:40 -0400 Message-ID: <20230417034540.2645965-1-ppalka@redhat.com> X-Mailer: git-send-email 2.40.0.335.g9857273be0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 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_H2, 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.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 Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold as per the current draft standard. libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (__cpp_lib_ranges_contains): Define for C++23. (__cpp_lib_ranges_iota): Likewise. (__cpp_lib_ranges_find_last): Likewise. (__cpp_lib_fold): Rename to ... (__cpp_lib_ranges_fold): ... this. * include/std/version: As above. * testsuite/25_algorithms/fold_left/1.cc: Adjust after renaming __cpp_lib_fold. * testsuite/std/ranges/version_c++23.cc: Verify values of the above feature-test macros. --- libstdc++-v3/include/bits/ranges_algo.h | 9 ++++++++- libstdc++-v3/include/std/version | 5 ++++- .../testsuite/25_algorithms/fold_left/1.cc | 4 ++-- .../testsuite/std/ranges/version_c++23.cc | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index f041ff16b0e..410d3ae1dd8 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -3468,6 +3468,9 @@ namespace ranges inline constexpr __prev_permutation_fn prev_permutation{}; #if __cplusplus > 202002L + +#define __cpp_lib_ranges_contains 202207L + struct __contains_fn { template _Sent, @@ -3521,6 +3524,8 @@ namespace ranges inline constexpr __contains_subrange_fn contains_subrange{}; +#define __cpp_lib_ranges_iota 202202L + template struct out_value_result { @@ -3569,6 +3574,8 @@ namespace ranges inline constexpr __iota_fn iota{}; +#define __cpp_lib_ranges_find_last 202207L + struct __find_last_fn { template _Sent, typename _Tp, typename _Proj = identity> @@ -3695,7 +3702,7 @@ namespace ranges inline constexpr __find_last_if_not_fn find_last_if_not{}; -#define __cpp_lib_fold 202207L +#define __cpp_lib_ranges_fold 202207L template struct in_value_result diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 9f31f25f1e9..027e5711ec5 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -341,7 +341,10 @@ #define __cpp_lib_ranges_as_rvalue 202207L #define __cpp_lib_ranges_as_const 202207L #define __cpp_lib_ranges_enumerate 202302L -#define __cpp_lib_fold 202207L +#define __cpp_lib_ranges_contains 202207L +#define __cpp_lib_ranges_iota 202202L +#define __cpp_lib_ranges_find_last 202207L +#define __cpp_lib_ranges_fold 202207L #if __cpp_constexpr_dynamic_alloc # if _GLIBCXX_HOSTED # define __cpp_lib_constexpr_bitset 202202L diff --git a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc index 5cc91b67d27..4041d13315f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc +++ b/libstdc++-v3/testsuite/25_algorithms/fold_left/1.cc @@ -5,8 +5,8 @@ #include #include -#if __cpp_lib_fold != 202207L -# error "Feature-test macro __cpp_lib_fold has wrong value in " +#if __cpp_lib_ranges_fold != 202207L +# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in " #endif namespace ranges = std::ranges; diff --git a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc index e2c14edc8ef..04609bb602c 100644 --- a/libstdc++-v3/testsuite/std/ranges/version_c++23.cc +++ b/libstdc++-v3/testsuite/std/ranges/version_c++23.cc @@ -52,3 +52,19 @@ #if __cpp_lib_ranges_enumerate != 202302L # error "Feature-test macro __cpp_lib_ranges_enumerate has wrong value in " #endif + +#if __cpp_lib_ranges_contains != 202207L +# error "Feature-test macro __cpp_lib_ranges_contains has wrong value in " +#endif + +#if __cpp_lib_ranges_iota != 202202L +# error "Feature-test macro __cpp_lib_ranges_iota has wrong value in " +#endif + +#if __cpp_lib_ranges_find_last != 202207L +# error "Feature-test macro __cpp_lib_ranges_find_last has wrong value in " +#endif + +#if __cpp_lib_ranges_fold != 202207L +# error "Feature-test macro __cpp_lib_ranges_fold has wrong value in " +#endif