Bug 95983 - `std::counted_iterator<std::iterator_t<std::ranges::basic_istream_view<...>>>` fails to satisfy `std::input_or_output_iterator`
Summary: `std::counted_iterator<std::iterator_t<std::ranges::basic_istream_view<...>>>...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 10.4
Assignee: Patrick Palka
URL:
Keywords: rejects-valid
: 96070 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-06-29 18:19 UTC by ensadc
Modified: 2021-05-04 20:21 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-07-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ensadc 2020-06-29 18:19:14 UTC
https://wandbox.org/permlink/rUZlUGG4UFeWicbM
====
#include <ranges>
#include <iterator>
#include <iostream>
using R =
  std::ranges::basic_istream_view<int, char, std::char_traits<char>>;
using It = std::ranges::iterator_t<R>;
static_assert(std::input_or_output_iterator<std::counted_iterator<It>>);

====
prog.cc:5:20: error: static assertion failed
    5 | static_assert(std::input_or_output_iterator<std::counted_iterator<T>>);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:5:20: note: constraints not satisfied
In file included from /opt/wandbox/gcc-head/include/c++/11.0.0/bits/stl_iterator_base_types.h:71,
                 from /opt/wandbox/gcc-head/include/c++/11.0.0/iterator:61,
                 from /opt/wandbox/gcc-head/include/c++/11.0.0/ranges:44,
                 from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/11.0.0/bits/iterator_concepts.h:536:13:   required for the satisfaction of 'weakly_incrementable<_Iter>' [with _Iter = std::counted_iterator<std::ranges::basic_istream_view<int, char, std::char_traits<char> >::_Iterator<int, char, std::char_traits<char> > >]
/opt/wandbox/gcc-head/include/c++/11.0.0/bits/iterator_concepts.h:538:10:   in requirements with '_Iter __i' [with _Tp = std::counted_iterator<std::ranges::basic_istream_view<int, char, std::char_traits<char> >::_Iterator<int, char, std::char_traits<char> > >; _Iter = std::counted_iterator<std::ranges::basic_istream_view<int, char, std::char_traits<char> >::_Iterator<int, char, std::char_traits<char> > >]
/opt/wandbox/gcc-head/include/c++/11.0.0/bits/iterator_concepts.h:540:11: note: the required type 'std::iter_difference_t<_Iter>' is invalid
  540 |  typename iter_difference_t<_Iter>;
      |  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/11.0.0/bits/iterator_concepts.h:541:21: note: nested requirement '__is_signed_integer_like<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>' is not satisfied
  541 |  requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
      |           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more detail

====
It seems that in this case, `iter_difference_t` is treated as an alias of `std::iterator_traits<std::counted_iterator<It>>::difference_type` (which doesn't exist), because libstdc++ defines a specialization of `std::iterator_traits<std::counted_iterator<It>>`.

(The error message is worse than it should be, due to bug 94862 and bug 95303.)
Comment 1 Jonathan Wakely 2020-07-08 14:56:30 UTC
(In reply to ensadc from comment #0)
> It seems that in this case, `iter_difference_t` is treated as an alias of
> `std::iterator_traits<std::counted_iterator<It>>::difference_type` (which
> doesn't exist), because libstdc++ defines a specialization of
> `std::iterator_traits<std::counted_iterator<It>>`.

That specialization is required, see [counted.iterator], and we define it correctly.

This seems to be a defect in C++20. iter_difference_t<I> is required to use iterator_traits<I>::difference_type if iterator_traits<I> is specialized, which it is here. But the specialization doesn't define difference_type.

It doesn't matter that incrementable_traits<I>::difference_type is defined, because it doesn't get used.

I think the fix is (untested):

--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -2141,16 +2141,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       iter_difference_t<_It> _M_length = 0;
     };
 
-  template<typename _It>
-    struct incrementable_traits<counted_iterator<_It>>
-    {
-      using difference_type = iter_difference_t<_It>;
-    };
-
   template<input_iterator _It>
     struct iterator_traits<counted_iterator<_It>> : iterator_traits<_It>
     {
       using pointer = void;
+      using difference_type = iter_difference_t<_It>;
     };
 #endif // C++20
Comment 2 ensadc 2020-07-27 05:07:39 UTC
See also LWG 3408 (https://wg21.link/lwg3408), which also suggests that the `iterator_traits<counted_iterator<It>>` specialization is problematic.

I think the standard could remove this specialization (and define `iterator_concept` in `counted_iterator`), since this specialization seems to have only negative effect.
Comment 3 Patrick Palka 2021-04-20 03:52:09 UTC
P2259R1 (wg21.link/p2259r1) fixes this issue and similar ones.

Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568272.html
Comment 4 gcc-bugs 2021-04-20 07:45:57 UTC
Hi Patrick,

thank you for that patch. I guess that it also fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96070.

Will this patch be backported to gcc-10?

Great work!
Comment 5 GCC Commits 2021-04-20 13:19:14 UTC
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:902b40c797a86f76791c32d537ba06dff5f1ba27

commit r12-8-g902b40c797a86f76791c32d537ba06dff5f1ba27
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Apr 20 09:18:50 2021 -0400

    libstdc++: Implement P2259R1 changes [PR95983]
    
    This implements the wording changes of P2259R1 "Repairing input range
    adaptors and counted_iterator", which resolves LWG 3283, 3289 and 3408.
    
    The wording changes are relatively straightforward, but they require
    some boilerplate to implement: the changes to make a type alias
    "conditionally present" in some iterator class are realized by defining
    a base class template and an appropriately constrained partial
    specialization thereof that contains the type alias, and having the
    iterator class derive from this base class.  Sometimes the relevant
    condition depend on members from the iterator class, but because a
    class is incomplete when instantiating its bases, the constraints on
    the partial specialization can't use anything from the iterator class.
    This patch works around this by hoisting these members out to the
    enclosing scope (e.g. transform_view::_Iterator::_Base is hoisted out
    to transform_view::_Base so that transform_view::__iter_cat can use it).
    
    This patch also implements the proposed resolution of LWG 3291 to rename
    iota_view::iterator_category to iota_view::iterator_concept, which was
    previously problematic due to LWG 3408.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/95983
            * include/bits/stl_iterator.h (__detail::__move_iter_cat):
            Define.
            (move_iterator): Derive from the above in C++20 in order to
            conditionally define iterator_category as per P2259.
            (move_iterator::__base_cat): No longer used, so remove.
            (move_iterator::iterator_category): Remove in C++20.
            (__detail::__common_iter_use_postfix_proxy): Define.
            (common_iterator::_Proxy): Rename to ...
            (common_iterator:__arrow_proxy): ... this.
            (common_iterator::__postfix_proxy): Define as per P2259.
            (common_iterator::operator->): Adjust.
            (common_iterator::operator++): Adjust as per P2259.
            (iterator_traits<common_iterator>::_S_iter_cat): Define.
            (iterator_traits<common_iterator>::iterator_category): Change as
            per P2259.
            (__detail::__counted_iter_value_type): Define.
            (__detail::__counted_iter_concept): Define.
            (__detail::__counted_iter_cat): Define.
            (counted_iterator): Derive from the above three classes in order
            to conditionally define value_type, iterator_concept and
            iterator category respectively as per P2259.
            (counted_iterator::operator->): Define as per P2259.
            (incrementable_traits<counted_iterator>): Remove as per P2259.
            (iterator_traits<counted_iterator>): Adjust as per P2259.
            * include/std/ranges (__detail::__iota_view_iter_cat): Define.
            (iota_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (iota_view::_S_iter_cat): Rename to ...
            (iota_view::_S_iter_concept): ... this.
            (iota_view::iterator_concept): Use it to apply LWG 3291 changes.
            (iota_view::iterator_category): Remove.
            (__detail::__filter_view_iter_cat): Define.
            (filter_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (filter_view::_Iterator): Move to struct __filter_view_iter_cat.
            (filter_view::_Iterator::iterator_category): Remove.
            (transform_view::_Base): Define.
            (transform_view::__iter_cat): Define.
            (transform_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (transform_view::_Iterator::_Base): Just alias
            transform_view::_Base.
            (transform_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (transform_view::_Iterator::iterator_category): Remove.
            (transform_view::_Sentinel::_Base): Just alias
            transform_view::_Base.
            (join_view::_Base): Define.
            (join_view::_Outer_iter): Define.
            (join_view::_Inner_iter): Define.
            (join_view::_S_ref_is_glvalue): Define.
            (join_view::__iter_cat): Define.
            (join_view::_Iterator): Derive from it in order to conditionally
            define iterator_category as per P2259.
            (join_view::_Iterator::_Base): Just alias join_view::_Base.
            (join_view::_Iterator::_S_ref_is_glvalue): Just alias
            join_view::_S_ref_is_glvalue.
            (join_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (join_view::_Iterator::_Outer_iter): Just alias
            join_view::_Outer_iter.
            (join_view::_Iterator::_Inner_iter): Just alias
            join_view::_Inner_iter.
            (join_view::_Iterator::iterator_category): Remove.
            (join_view::_Sentinel::_Base): Just alias join_view::_Base.
            (__detail::__split_view_outer_iter_cat): Define.
            (__detail::__split_view_inner_iter_cat): Define.
            (split_view::_Base): Define.
            (split_view::_Outer_iter): Derive from __split_view_outer_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Outer_iter::iterator_category): Remove.
            (split_view::_Inner_iter): Derive from __split_view_inner_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Inner_iter::_S_iter_cat): Move to
            __split_view_inner_iter_cat.
            (split_view::_Inner_iter::iterator_category): Remove.
            (elements_view::_Base): Define.
            (elements_view::__iter_cat): Define.
            (elements_view::_Iterator): Derive from the above in order to
            conditionall define iterator_category as per P2259.
            (elements_view::_Iterator::_Base): Just alias
            elements_view::_Base.
            (elements_view::_Iterator::_S_iter_concept)
            (elements_view::_Iterator::iterator_concept): Define as per
            P2259.
            (elements_view::_Iterator::iterator_category): Remove.
            (elements_view::_Sentinel::_Base): Just alias
            elements_view::_Base.
            * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc:
            Adjust constraints on iterator_traits<counted_iterator>.
            * testsuite/std/ranges/p2259.cc: New test.
Comment 6 GCC Commits 2021-04-20 13:20:12 UTC
The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:eecefcb78c311b509d9fac2fe38b5b293e095bec

commit r11-8262-geecefcb78c311b509d9fac2fe38b5b293e095bec
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Apr 20 09:18:50 2021 -0400

    libstdc++: Implement P2259R1 changes [PR95983]
    
    This implements the wording changes of P2259R1 "Repairing input range
    adaptors and counted_iterator", which resolves LWG 3283, 3289 and 3408.
    
    The wording changes are relatively straightforward, but they require
    some boilerplate to implement: the changes to make a type alias
    "conditionally present" in some iterator class are realized by defining
    a base class template and an appropriately constrained partial
    specialization thereof that contains the type alias, and having the
    iterator class derive from this base class.  Sometimes the relevant
    condition depend on members from the iterator class, but because a
    class is incomplete when instantiating its bases, the constraints on
    the partial specialization can't use anything from the iterator class.
    This patch works around this by hoisting these members out to the
    enclosing scope (e.g. transform_view::_Iterator::_Base is hoisted out
    to transform_view::_Base so that transform_view::__iter_cat can use it).
    
    This patch also implements the proposed resolution of LWG 3291 to rename
    iota_view::iterator_category to iota_view::iterator_concept, which was
    previously problematic due to LWG 3408.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/95983
            * include/bits/stl_iterator.h (__detail::__move_iter_cat):
            Define.
            (move_iterator): Derive from the above in C++20 in order to
            conditionally define iterator_category as per P2259.
            (move_iterator::__base_cat): No longer used, so remove.
            (move_iterator::iterator_category): Remove in C++20.
            (__detail::__common_iter_use_postfix_proxy): Define.
            (common_iterator::_Proxy): Rename to ...
            (common_iterator:__arrow_proxy): ... this.
            (common_iterator::__postfix_proxy): Define as per P2259.
            (common_iterator::operator->): Adjust.
            (common_iterator::operator++): Adjust as per P2259.
            (iterator_traits<common_iterator>::_S_iter_cat): Define.
            (iterator_traits<common_iterator>::iterator_category): Change as
            per P2259.
            (__detail::__counted_iter_value_type): Define.
            (__detail::__counted_iter_concept): Define.
            (__detail::__counted_iter_cat): Define.
            (counted_iterator): Derive from the above three classes in order
            to conditionally define value_type, iterator_concept and
            iterator category respectively as per P2259.
            (counted_iterator::operator->): Define as per P2259.
            (incrementable_traits<counted_iterator>): Remove as per P2259.
            (iterator_traits<counted_iterator>): Adjust as per P2259.
            * include/std/ranges (__detail::__iota_view_iter_cat): Define.
            (iota_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (iota_view::_S_iter_cat): Rename to ...
            (iota_view::_S_iter_concept): ... this.
            (iota_view::iterator_concept): Use it to apply LWG 3291 changes.
            (iota_view::iterator_category): Remove.
            (__detail::__filter_view_iter_cat): Define.
            (filter_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (filter_view::_Iterator): Move to struct __filter_view_iter_cat.
            (filter_view::_Iterator::iterator_category): Remove.
            (transform_view::_Base): Define.
            (transform_view::__iter_cat): Define.
            (transform_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (transform_view::_Iterator::_Base): Just alias
            transform_view::_Base.
            (transform_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (transform_view::_Iterator::iterator_category): Remove.
            (transform_view::_Sentinel::_Base): Just alias
            transform_view::_Base.
            (join_view::_Base): Define.
            (join_view::_Outer_iter): Define.
            (join_view::_Inner_iter): Define.
            (join_view::_S_ref_is_glvalue): Define.
            (join_view::__iter_cat): Define.
            (join_view::_Iterator): Derive from it in order to conditionally
            define iterator_category as per P2259.
            (join_view::_Iterator::_Base): Just alias join_view::_Base.
            (join_view::_Iterator::_S_ref_is_glvalue): Just alias
            join_view::_S_ref_is_glvalue.
            (join_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (join_view::_Iterator::_Outer_iter): Just alias
            join_view::_Outer_iter.
            (join_view::_Iterator::_Inner_iter): Just alias
            join_view::_Inner_iter.
            (join_view::_Iterator::iterator_category): Remove.
            (join_view::_Sentinel::_Base): Just alias join_view::_Base.
            (__detail::__split_view_outer_iter_cat): Define.
            (__detail::__split_view_inner_iter_cat): Define.
            (split_view::_Base): Define.
            (split_view::_Outer_iter): Derive from __split_view_outer_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Outer_iter::iterator_category): Remove.
            (split_view::_Inner_iter): Derive from __split_view_inner_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Inner_iter::_S_iter_cat): Move to
            __split_view_inner_iter_cat.
            (split_view::_Inner_iter::iterator_category): Remove.
            (elements_view::_Base): Define.
            (elements_view::__iter_cat): Define.
            (elements_view::_Iterator): Derive from the above in order to
            conditionall define iterator_category as per P2259.
            (elements_view::_Iterator::_Base): Just alias
            elements_view::_Base.
            (elements_view::_Iterator::_S_iter_concept)
            (elements_view::_Iterator::iterator_concept): Define as per
            P2259.
            (elements_view::_Iterator::iterator_category): Remove.
            (elements_view::_Sentinel::_Base): Just alias
            elements_view::_Base.
            * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc:
            Adjust constraints on iterator_traits<counted_iterator>.
            * testsuite/std/ranges/p2259.cc: New test.
    
    (cherry picked from commit 902b40c797a86f76791c32d537ba06dff5f1ba27)
Comment 7 Patrick Palka 2021-04-20 15:39:12 UTC
*** Bug 96070 has been marked as a duplicate of this bug. ***
Comment 8 Patrick Palka 2021-04-20 15:59:50 UTC
(In reply to gcc-bugs from comment #4)
> Hi Patrick,
> 
> thank you for that patch. I guess that it also fixes
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96070.

Ah indeed, thanks.  The testcase there seems similar enough to mark the PR as a dup of this one.

> 
> Will this patch be backported to gcc-10?

I believe so; fortunately, the patch applies pretty cleanly to the 10 branch, so I don't expect many changes will be needed in order to backport.
Comment 9 GCC Commits 2021-05-04 13:51:00 UTC
The releases/gcc-10 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:1cb39945993c89746b0347746bd1267de85cbc42

commit r10-9796-g1cb39945993c89746b0347746bd1267de85cbc42
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Apr 20 09:18:50 2021 -0400

    libstdc++: Implement P2259R1 changes [PR95983]
    
    This implements the wording changes of P2259R1 "Repairing input range
    adaptors and counted_iterator", which resolves LWG 3283, 3289 and 3408.
    
    The wording changes are relatively straightforward, but they require
    some boilerplate to implement: the changes to make a type alias
    "conditionally present" in some iterator class are realized by defining
    a base class template and an appropriately constrained partial
    specialization thereof that contains the type alias, and having the
    iterator class derive from this base class.  Sometimes the relevant
    condition depend on members from the iterator class, but because a
    class is incomplete when instantiating its bases, the constraints on
    the partial specialization can't use anything from the iterator class.
    This patch works around this by hoisting these members out to the
    enclosing scope (e.g. transform_view::_Iterator::_Base is hoisted out
    to transform_view::_Base so that transform_view::__iter_cat can use it).
    
    This patch also implements the proposed resolution of LWG 3291 to rename
    iota_view::iterator_category to iota_view::iterator_concept, which was
    previously problematic due to LWG 3408.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/95983
            * include/bits/stl_iterator.h (__detail::__move_iter_cat):
            Define.
            (move_iterator): Derive from the above in C++20 in order to
            conditionally define iterator_category as per P2259.
            (move_iterator::__base_cat): No longer used, so remove.
            (move_iterator::iterator_category): Remove in C++20.
            (__detail::__common_iter_use_postfix_proxy): Define.
            (common_iterator::_Proxy): Rename to ...
            (common_iterator:__arrow_proxy): ... this.
            (common_iterator::__postfix_proxy): Define as per P2259.
            (common_iterator::operator->): Adjust.
            (common_iterator::operator++): Adjust as per P2259.
            (iterator_traits<common_iterator>::_S_iter_cat): Define.
            (iterator_traits<common_iterator>::iterator_category): Change as
            per P2259.
            (__detail::__counted_iter_value_type): Define.
            (__detail::__counted_iter_concept): Define.
            (__detail::__counted_iter_cat): Define.
            (counted_iterator): Derive from the above three classes in order
            to conditionally define value_type, iterator_concept and
            iterator category respectively as per P2259.
            (counted_iterator::operator->): Define as per P2259.
            (incrementable_traits<counted_iterator>): Remove as per P2259.
            (iterator_traits<counted_iterator>): Adjust as per P2259.
            * include/std/ranges (__detail::__iota_view_iter_cat): Define.
            (iota_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (iota_view::_S_iter_cat): Rename to ...
            (iota_view::_S_iter_concept): ... this.
            (iota_view::iterator_concept): Use it to apply LWG 3291 changes.
            (iota_view::iterator_category): Remove.
            (__detail::__filter_view_iter_cat): Define.
            (filter_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (filter_view::_Iterator): Move to struct __filter_view_iter_cat.
            (filter_view::_Iterator::iterator_category): Remove.
            (transform_view::_Base): Define.
            (transform_view::__iter_cat): Define.
            (transform_view::_Iterator): Derive from the above in order to
            conditionally define iterator_category as per P2259.
            (transform_view::_Iterator::_Base): Just alias
            transform_view::_Base.
            (transform_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (transform_view::_Iterator::iterator_category): Remove.
            (transform_view::_Sentinel::_Base): Just alias
            transform_view::_Base.
            (join_view::_Base): Define.
            (join_view::_Outer_iter): Define.
            (join_view::_Inner_iter): Define.
            (join_view::_S_ref_is_glvalue): Define.
            (join_view::__iter_cat): Define.
            (join_view::_Iterator): Derive from it in order to conditionally
            define iterator_category as per P2259.
            (join_view::_Iterator::_Base): Just alias join_view::_Base.
            (join_view::_Iterator::_S_ref_is_glvalue): Just alias
            join_view::_S_ref_is_glvalue.
            (join_view::_Iterator::_S_iter_cat): Move to struct
            transform_view::__iter_cat.
            (join_view::_Iterator::_Outer_iter): Just alias
            join_view::_Outer_iter.
            (join_view::_Iterator::_Inner_iter): Just alias
            join_view::_Inner_iter.
            (join_view::_Iterator::iterator_category): Remove.
            (join_view::_Sentinel::_Base): Just alias join_view::_Base.
            (__detail::__split_view_outer_iter_cat): Define.
            (__detail::__split_view_inner_iter_cat): Define.
            (split_view::_Base): Define.
            (split_view::_Outer_iter): Derive from __split_view_outer_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Outer_iter::iterator_category): Remove.
            (split_view::_Inner_iter): Derive from __split_view_inner_iter_cat
            in order to conditionally define iterator_category as per P2259.
            (split_view::_Inner_iter::_S_iter_cat): Move to
            __split_view_inner_iter_cat.
            (split_view::_Inner_iter::iterator_category): Remove.
            (elements_view::_Base): Define.
            (elements_view::__iter_cat): Define.
            (elements_view::_Iterator): Derive from the above in order to
            conditionall define iterator_category as per P2259.
            (elements_view::_Iterator::_Base): Just alias
            elements_view::_Base.
            (elements_view::_Iterator::_S_iter_concept)
            (elements_view::_Iterator::iterator_concept): Define as per
            P2259.
            (elements_view::_Iterator::iterator_category): Remove.
            (elements_view::_Sentinel::_Base): Just alias
            elements_view::_Base.
            * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc:
            Adjust constraints on iterator_traits<counted_iterator>.
            * testsuite/std/ranges/p2259.cc: New test.
    
    (cherry picked from commit 902b40c797a86f76791c32d537ba06dff5f1ba27)
Comment 10 Patrick Palka 2021-05-04 13:52:57 UTC
Fixed for 10.4/11/12.
Comment 11 gcc-bugs 2021-05-04 20:21:32 UTC
Thank you so much!