]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Implement reverse iteration for _Utf_view
authorJonathan Wakely <jwakely@redhat.com>
Mon, 14 Jul 2025 19:15:12 +0000 (20:15 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 18 Jul 2025 09:29:58 +0000 (10:29 +0100)
commitbc3de0014aa91c43ec83d27c7f2a13a145f6d82b
treebf09938a1a8ade580ce05fbb91a61a0fe5e81ba6
parented6a9cfc4af84ef49773b53fdfa06e65fbb31895
libstdc++: Implement reverse iteration for _Utf_view

This implements the missing functions in _Utf_iterator to support
reverse iteration. All existing tests pass when the view is reversed, so
that the same code units are seen when iterating forwards or backwards.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Utf_iterator::operator--): Reorder
conditions and update position after reading a code unit.
(_Utf_iterator::_M_read_reverse): Define.
(_Utf_iterator::_M_read_utf8): Return extracted code point.
(_Utf_iterator::_M_read_reverse_utf8): Define.
(_Utf_iterator::_M_read_reverse_utf16): Define.
(_Utf_iterator::_M_read_reverse_utf32): Define.
* testsuite/ext/unicode/view.cc: Add checks for reversed views
and reverse iteration.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/bits/unicode.h
libstdc++-v3/testsuite/ext/unicode/view.cc