mirror of git://gcc.gnu.org/git/gcc.git
Previously, _Utf_view accepted any input_range, including reference-to-array types like char(&)[2], and stored it as the _M_base member. In such cases, _Utf_view was not assignable, failing the requirements of view concept. This patch addresses the issue by adding the ranges::view constraint to the second template parameter of _Utf_view, and for clarity renaming it from _Range to _View. The constructor is also adjusted to accept its argument by value (views must be O(1) move-constructible). This prevents implicitly generated CTAD from deducing a reference type. This makes _Utf_view consistent with both other standard views and the wording from P2728R8: Unicode in the Library, Part 1: UTF Transcoding [1]. The explicit CTAD from viewable_range is not defined for _Utf_view because it depends on views::all_t, views::ref_view, and views::owning_view, which are declared in <ranges>. Consequently, users must explicitly cast the argument to a view or specify it as a template parameter. [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2728r8.html libstdc++-v3/ChangeLog: * include/bits/unicode.h (_Utf_view): Rename the template parameter from _Range to _View and constrain it with ranges::view. (_Utf_view::_Utf_view): Accept by value instead of rvalue reference. * include/std/format (__format::__write_padded): Replace _Utf_view over const char32_t(&)[1] with span<const char32_t, 1>. * testsuite/ext/unicode/view.cc: Add checks if specialization of _Utf_view satisfy view. Wrap arrays into std::span before constructing _Utf_view. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com> |
||
|---|---|---|
| .. | ||
| charset_alias_match.cc | ||
| grapheme_view.cc | ||
| properties.cc | ||
| view.cc | ||