From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 384EC3856180; Mon, 24 Oct 2022 02:28:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 384EC3856180 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666578493; bh=Pwae749tgcgSd/07EFsFxzfXb6+Ja2UIRkzy6K+jH4U=; h=From:To:Subject:Date:From; b=O/9kRNRrMuaUluGLjwktNxClESLEwDurJFoKL+QF+4+EBnVvDOZBDhNr7WufiXD8X kVEIewSSbHNyYQ0ktAB730EBTxz8ZEtgQPz6mynTbXTS+vAlxTABnDZ2Crlca+Tuwl adX5MhBYSILggFKIM569d0Hd7StsxoZ5sX3XCPR0= From: "unlvsur at live dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107367] New: All standard library algorithms should detect whether they are contiguous iterators after C++20 Date: Mon, 24 Oct 2022 02:28:12 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: unlvsur at live 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107367 Bug ID: 107367 Summary: All standard library algorithms should detect whether they are contiguous iterators after C++20 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: unlvsur at live dot com Target Milestone: --- https://github.com/gcc-mirror/gcc/blob/00716b776200c2de6813ce706d2757eec4cb= 2735/libstdc%2B%2B-v3/include/bits/stl_algo.h#L3229 Take is_sorted for example: template _GLIBCXX20_CONSTEXPR inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { return std::is_sorted_until(__first, __last) =3D=3D __last; } It should be optimized to template _GLIBCXX20_CONSTEXPR inline bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) {=20 if constexpr(contiguous_iterator<_ForwardIterator>&&!is_pointer_v<_ForwardIter= ator>) { return is_sorted(to_address(__first),to_address(__last)); } else { return std::is_sorted_until(__first, __last) =3D=3D __last;=20 } }=