From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 206823858D35; Mon, 6 Jul 2020 02:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 206823858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594001290; bh=fAhZaxfOy+O6ktR1lyzhigQ7t9g22HNBnLqx8DQX3Kg=; h=From:To:Subject:Date:From; b=U1dtytxShPiGG99Hnj366O9KXjABtZyPM6iy4IgbJfnFvVkk9PCWTzej5y3Pnq+Xx pWjxN4aZSF6ZGtOXUVCU7/y78gknyP+O9NoDNmISG2QlAM/K93VKLO9g7CAEoX0P2Y koDosrItn4eCt+e4MLhZXbTs0rRvZRUGF1VkursE= From: "gcc-bugs at marehr dot dialup.fu-berlin.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators Date: Mon, 06 Jul 2020 02:08:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc-bugs at marehr dot dialup.fu-berlin.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2020 02:08:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96070 Bug ID: 96070 Summary: std::views::* won't work with non-legacy iterators Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de Target Milestone: --- Hi gcc-team, not long ago a filed a bug-report[1] that `std::ranges::basic_istream_view::iterator` has no `std::iterator_traits` entry.=20 > Your mistake is thinking that the iterators of views are like the iterato= rs you're used to. It seems that not only I had that problem, because this has some interesting consequences for the standard, for example the `std::ranges::filter_view::iterator` is described as [2]: > 3 iterator=E2=80=8B::=E2=80=8Biterator_=C2=ADcategory is defined as follo= ws: > (3.1) Let C denote the type iterator_=C2=ADtraits>=E2= =80=8B::=E2=80=8Biterator_=C2=ADcategory. > (3.2) If C models derived_=C2=ADfrom, then iterator_=C2=ADcategory denotes bidirectional_=C2=ADiterator_=C2= =ADtag. > (3.3) Otherwise, if C models derived_=C2=ADfrom, then iterator_=C2=ADcategory denotes forward_=C2=ADiterator_=C2= =ADtag. > (3.4) Otherwise, iterator_=C2=ADcategory denotes C. This assumes that `iterator_=C2=ADtraits>=E2=80=8B::=E2= =80=8Biterator_=C2=ADcategory` is defined which is not true for all iterators, like `std::ranges::basic_istream_view::iterator`. A quick check with the gcc stdlib implementation: ```c++ #include #include #include int main() { // using input_view_t =3D std::vector &; // works using input_view_t =3D std::ranges::basic_istream_view>; // does not work auto accept_all =3D [](auto &&){return true;}; using filter_input_view_t =3D decltype(std::declval() | std::views::filter(accept_all)); using filter_iterator_t =3D std::ranges::iterator_t; } ``` https://godbolt.org/z/Uozktw And yes it does not work. Since I don't know of a generic way to conditionally include/exclude `using iterator_category =3D some_tag`, I think the easiest way would to allow `iterator_category =3D void`. We would need to change the behaviour of `std::iterator_traits`. We should = not only check whether all 4 members are available, but also that `iterator_category` is at least an input_iterator_tag or an output_iterator_tag. Or alternatively check that `iterator_category` is non-void. I don't know how to create a LWG issue and if this problem was already reported, but I hope you can create one like in my last finding [3]. If this defect was not reported yet, it would be nice to at least link back= to this issue and not just write "A user reported that this doesn't compile: ". [1] - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94674 [2] - https://eel.is/c++draft/range.filter.iterator#3 [3] - https://cplusplus.github.io/LWG/issue3448=