https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100070

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'm not sure we should make std::__iterator_category just return
std::__detail::__iter_concept, because that has a fallback of
random_access_iterator_tag and I keep forgetting why that is. And I don't think
it's what we want here.

So just:

--- a/libstdc++-v3/include/bits/stl_iterator_base_types.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h
@@ -236,7 +236,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline _GLIBCXX_CONSTEXPR
     typename iterator_traits<_Iter>::iterator_category
     __iterator_category(const _Iter&)
-    { return typename iterator_traits<_Iter>::iterator_category(); }
+    {
+#if __cpp_lib_concepts
+      if constexpr (random_access_iterator<_Iter>)
+       return random_access_iterator_tag{};
+      else if constexpr (bidirectional_iterator<_Iter>)
+       return bidirectional_iterator_tag{};
+      else if constexpr (forward_iterator<_Iter>)
+       return forward_iterator_tag{};
+      else
+#endif
+      return typename iterator_traits<_Iter>::iterator_category();
+    }

   ///@}

Reply via email to