From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 024743857001; Thu, 2 Sep 2021 21:59:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 024743857001 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/102181] std::advance and std::views::iota don't work Date: Thu, 02 Sep 2021 21:59:19 +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: redi at gcc dot gnu.org 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: Thu, 02 Sep 2021 21:59:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102181 --- Comment #4 from Jonathan Wakely --- https://en.cppreference.com/w/cpp/iterator/advance says "InputIt must meet = the requirements of LegacyInputIterator." https://en.cppreference.com/w/cpp/named_req/InputIterator gives a sample concept you can use to test whether something meets those requirements. The iterator_t> type does not satisfy that concept. I think GCC is behaving according to the standard. You can use std::ranges::advance because that requires std::input_or_output_iterator, which is satisfied by your iota_view's itera= tor. #include int main() { using type =3D std::int64_t; // using type =3D int works! auto v =3D std::views::iota(static_cast(0), static_cast(100)); auto b =3D v.begin(); static_assert( ! __LegacyInputIterator ); // So this can't work: // std::advance(b, 1); static_assert( std::input_iterator ); // So this can work: std::ranges::advance(b, static_cast(1)); }=