From patchwork Thu Aug 10 22:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 134243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp727070vqi; Thu, 10 Aug 2023 15:36:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgoiKYyneHMX0R20aueMy9InC91ZQV38FfOSkd+qsKzjjWQSvjGFCH6MywA30PJsxqIgz6 X-Received: by 2002:a17:906:c1:b0:99c:6671:66fa with SMTP id 1-20020a17090600c100b0099c667166famr177886eji.51.1691706961957; Thu, 10 Aug 2023 15:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691706961; cv=none; d=google.com; s=arc-20160816; b=OkJHrHQ8fsChNKaBLFSW7/nGoaNIbatrzeMZU3RMcfAqB5W4ozcVBcpysQyFkUIwNY thQ5nF6vVb/vjZmyEvt3V3uhBLn6fDxKPUTdEmEXzXg8rGPcsqud3ubTMX5YGGCAZA6E 2/jh34kT1/P8mNfnjj18vyRUUTa13JUm67hEVeChG5DuvkeiNZcPu+rW1Pa7JrfUeJQ6 FwZilk2i09yFMnb0Hc+CbGdwunf80GGfaSFFRRONi4MiDwejt3uoxLtM8ob8QJDWpZ00 EwejOnZTaP+s4pjLY9CWI5ta3Vt7o3evBOnDfgX4UQTToVwHBBmMNQavRS68XW9FQ7Ak xVmw== 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 :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Q7e/7zgklEDsSNGYSHFTMuOZpNxfHSeHWHcjIyGn6Vk=; fh=sC8lnOfyH6gL5FYlMbZ1VDz6qVPMj/3ViLJWKNUCUgQ=; b=V75u+u1bRznJZ5XH0yrwdXf0IwodSHCLI2S2lcApYJVtM+bI8H6lH698mFzgew1T9s ITQxzsTLi1ZuoopbNJ1SnEBNXqfN/BBr2uNkCM9NNwbfsriOKmwHPQmWTmVZYfwn/u6s wpK2IWrP8g7kE3RgjWmQesyBMthn3UGFhCJyaTIfY7wO06j68KEEXiv5lT2mnwsZ/EcV UEUoeeceEIkgT6iVDn+eKvy0kRL3lU3UM3dt2ZvPXsoZ2KT39DI+UMfbZsCCQkqkLJYS GZtV+hV+dZ705+0+TSO/VH0PVgs43PuyWWK9yK+abf5A3BqYm4tt8ScUK7APx3DutcRn M0Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cmLBHnt9; 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 y15-20020a1709064b0f00b00988796c2019si2231549eju.591.2023.08.10.15.36.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 15:36:01 -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=cmLBHnt9; 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 2D2F23857B98 for ; Thu, 10 Aug 2023 22:35:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D2F23857B98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691706922; bh=Q7e/7zgklEDsSNGYSHFTMuOZpNxfHSeHWHcjIyGn6Vk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cmLBHnt9cCvJp5uHh/Rsc0YL8lX2BLd3qPxlT5ZaVsAg/nVLPvr5uqTQWAkoVhflM SQdNYiwSY9SwWa06gLstCd2puSiOAlKJads0i8JfEwJlxQS1IqUnLiDVCu+HI2Q+5F 4eSSE++M2KduAIO/OCf0Ln9w+5lDw7Tx2Nw+3L7Q= 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 538083858CDB for ; Thu, 10 Aug 2023 22:33:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 538083858CDB Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-ZZVRIb84PqGEcaMAzb2QHg-1; Thu, 10 Aug 2023 18:33:45 -0400 X-MC-Unique: ZZVRIb84PqGEcaMAzb2QHg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 853A18015AA; Thu, 10 Aug 2023 22:33:45 +0000 (UTC) Received: from localhost (unknown [10.42.28.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CD322026D4B; Thu, 10 Aug 2023 22:33:45 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use alias template for iterator_category [PR110970] Date: Thu, 10 Aug 2023 23:32:21 +0100 Message-ID: <20230810223344.1242452-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773883319431417778 X-GMAIL-MSGID: 1773883319431417778 Tested x86_64-linux. Pushed to trunk. Backport to gcc-13 to follow. -- >8 -- This renames __iterator_category_t to __iter_category_t, for consistency with std::iter_value_t, std::iter_difference_t and std::iter_reference_t in C++20. Then use __iter_category_t in , which fixes the problem of the missing 'typename' that Clang 15 incorrectly still requires. libstdc++-v3/ChangeLog: PR libstdc++/110970 * include/bits/stl_iterator.h (__detail::__move_iter_cat): Use __iter_category_t. (iterator_traits>::_S_iter_cat): Likewise. (__detail::__basic_const_iterator_iter_cat): Likewise. * include/bits/stl_iterator_base_types.h (__iterator_category_t): Rename to __iter_category_t. --- libstdc++-v3/include/bits/stl_iterator.h | 17 +++++++++-------- .../include/bits/stl_iterator_base_types.h | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index b22d9a4fdb3..d5ba05f3e22 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -103,6 +103,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __clamp_iter_cat = __conditional_t, _Limit, _Otherwise>; + template + using __clamped_iter_cat_t + = __clamp_iter_cat<__iter_category_t<_Iter>, _Limit>; + template concept __different_from = !same_as, remove_cvref_t<_Up>>; @@ -168,8 +172,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION random_access_iterator_tag, bidirectional_iterator_tag>; using iterator_category - = __detail::__clamp_iter_cat; + = __detail::__clamped_iter_cat_t<_Iterator, random_access_iterator_tag>; using value_type = iter_value_t<_Iterator>; using difference_type = iter_difference_t<_Iterator>; using reference = iter_reference_t<_Iterator>; @@ -1426,12 +1429,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; template - requires requires { typename iterator_traits<_Iterator>::iterator_category; } + requires requires { typename __iter_category_t<_Iterator>; } struct __move_iter_cat<_Iterator> { using iterator_category - = __clamp_iter_cat::iterator_category, - random_access_iterator_tag>; + = __clamped_iter_cat_t<_Iterator, random_access_iterator_tag>; }; #endif } @@ -2288,8 +2290,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static auto _S_iter_cat() { - using _Traits = iterator_traits<_It>; - if constexpr (requires { requires derived_from, forward_iterator_tag>; }) return forward_iterator_tag{}; else @@ -2615,7 +2616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __basic_const_iterator_iter_cat<_It> - { using iterator_category = iterator_traits<_It>::iterator_category; }; + { using iterator_category = __iter_category_t<_It>; }; } // namespace detail template diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h index 5d2c8b325d9..841b5eca3ad 100644 --- a/libstdc++-v3/include/bits/stl_iterator_base_types.h +++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h @@ -243,16 +243,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L template - using __iterator_category_t + using __iter_category_t = typename iterator_traits<_Iter>::iterator_category; template using _RequireInputIter = - __enable_if_t, + __enable_if_t, input_iterator_tag>::value>; template> + typename _Cat = __iter_category_t<_It>> struct __is_random_access_iter : is_base_of {