From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 03D5E384A029; Mon, 17 May 2021 04:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03D5E384A029 From: "hewillk at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100631] ranges::elements_view:: _Sentinel is missing __distance_from() that can access _M_current of _Iterator Date: Mon, 17 May 2021 04:50:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hewillk at gmail dot com 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: Message-ID: In-Reply-To: References: 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, 17 May 2021 04:50:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100631 --- Comment #2 from =E5=BA=B7=E6=A1=93=E7=91=8B = --- In addition, I think elements_view::_Sentinel::_M_equal should be a template function, and elements_view::_Iterator also needs to declare _Sentinel as a friend, otherwise the following valid codes will be rejected: https://godbolt.org/z/7aa75vqsP #include int main() { auto r =3D std::views::iota(0) | std::views::transform([](int) { return std::make_pair(42, "hello"); }) | std::views::keys; auto b =3D std::ranges::cbegin(r); auto e =3D std::end(r); b.base() =3D=3D e.base(); b =3D=3D e; // error } :12:9: required from here /opt/compiler-explorer/gcc-trunk-20210513/include/c++/12.0.0/ranges:3675:34: error: cannot convert 'const std::ranges::elements_view, main():: >, 0>::_Iterator'= to 'const std::ranges::elements_view, main():: >, 0>::_Iterator= &' 3675 | { return __y._M_equal(__x); } | ~~~~~~~~~~~~^~~~~ /opt/compiler-explorer/gcc-trunk-20210513/include/c++/12.0.0/ranges:3645:45: note: initializing argument 1 of 'constexpr bool std::ranges::elements_view<_Vp, _Nm>::_Sentinel<_Const>::_M_equal(const std::ranges::elements_view<_Vp, _Nm>::_Iterator<_Const>&) const [with bool _Const =3D false; _Vp =3D std::ranges::transform_view, main():: >; long unsigned int _N= m =3D 0]' 3645 | _M_equal(const _Iterator<_Const>& __x) const | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~=