public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-7710] libstdc++: Use alias template for iterator_category [PR110970]
Date: Fri, 11 Aug 2023 15:36:50 +0000 (GMT)	[thread overview]
Message-ID: <20230811153650.EA17F3858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:2e094543715fbd1a5486d77dcbfeec52d86aba61

commit r13-7710-g2e094543715fbd1a5486d77dcbfeec52d86aba61
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 10 13:48:48 2023 +0100

    libstdc++: Use alias template for iterator_category [PR110970]
    
    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 <bits/stl_iterator.h>, 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<common_iterator<I, S>>::_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.
    
    (cherry picked from commit 9cb2a7c8d54b1f6685bc509a07104c458262cb9f)

Diff:
---
 libstdc++-v3/include/bits/stl_iterator.h            | 9 ++++-----
 libstdc++-v3/include/bits/stl_iterator_base_types.h | 6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index b22d9a4fdb3a..b13f4f8ddbfb 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1426,11 +1426,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { };
 
     template<typename _Iterator>
-      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<typename iterator_traits<_Iterator>::iterator_category,
+	  = __clamp_iter_cat<__iter_category_t<_Iterator>,
 			     random_access_iterator_tag>;
       };
 #endif
@@ -2288,8 +2288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static auto
       _S_iter_cat()
       {
-	using _Traits = iterator_traits<_It>;
-	if constexpr (requires { requires derived_from<typename _Traits::iterator_category,
+	if constexpr (requires { requires derived_from<__iter_category_t<_It>,
 						       forward_iterator_tag>; })
 	  return forward_iterator_tag{};
 	else
@@ -2615,7 +2614,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     template<forward_iterator _It>
       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<input_iterator _It>
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h
index 5d2c8b325d9f..841b5eca3ad1 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<typename _Iter>
-    using __iterator_category_t
+    using __iter_category_t
       = typename iterator_traits<_Iter>::iterator_category;
 
   template<typename _InIter>
     using _RequireInputIter =
-      __enable_if_t<is_convertible<__iterator_category_t<_InIter>,
+      __enable_if_t<is_convertible<__iter_category_t<_InIter>,
 				   input_iterator_tag>::value>;
 
   template<typename _It,
-	   typename _Cat = __iterator_category_t<_It>>
+	   typename _Cat = __iter_category_t<_It>>
     struct __is_random_access_iter
       : is_base_of<random_access_iterator_tag, _Cat>
     {

                 reply	other threads:[~2023-08-11 15:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811153650.EA17F3858D28@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).