diff --git a/libstdc++-v3/include/bits/unicode.h b/libstdc++-v3/include/bits/unicode.h index 44872db4ed68..09f7c2d7bfb3 100644 --- a/libstdc++-v3/include/bits/unicode.h +++ b/libstdc++-v3/include/bits/unicode.h @@ -695,13 +695,14 @@ namespace __unicode friend class _Utf_iterator; }; - template + template + requires ranges::view<_View> class _Utf_view - : public ranges::view_interface<_Utf_view<_ToFormat, _Range>> + : public ranges::view_interface<_Utf_view<_ToFormat, _View>> { - using _Iterator = _Utf_iterator, - _ToFormat, ranges::iterator_t<_Range>, - ranges::sentinel_t<_Range>>; + using _Iterator = _Utf_iterator, + _ToFormat, ranges::iterator_t<_View>, + ranges::sentinel_t<_View>>; template constexpr auto @@ -725,11 +726,11 @@ namespace __unicode return _Iterator(__last, __last); } - _Range _M_base; + _View _M_base; public: constexpr explicit - _Utf_view(_Range&& __r) : _M_base(std::forward<_Range>(__r)) { } + _Utf_view(_View __r) : _M_base(std::move(__r)) { } constexpr auto begin() { return _M_begin(ranges::begin(_M_base), ranges::end(_M_base)); } diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 1102ac8f6e8a..f64f35a202e0 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -845,7 +845,7 @@ namespace __format { // Encode fill char as multiple code units of type _CharT. const char32_t __arr[1]{ __fill_char }; - _Utf_view<_CharT, const char32_t(&)[1]> __v(__arr); + _Utf_view<_CharT, span> __v(__arr); basic_string<_CharT> __padstr(__v.begin(), __v.end()); __padding = __padstr; while (__l-- > 0) diff --git a/libstdc++-v3/testsuite/ext/unicode/view.cc b/libstdc++-v3/testsuite/ext/unicode/view.cc index 40c8fcf34fb7..677a21d8c1f5 100644 --- a/libstdc++-v3/testsuite/ext/unicode/view.cc +++ b/libstdc++-v3/testsuite/ext/unicode/view.cc @@ -7,6 +7,10 @@ namespace uc = std::__unicode; using namespace std::string_view_literals; +static_assert( std::ranges::view> ); +static_assert( std::ranges::view> ); +static_assert( std::ranges::view> ); + template constexpr void compare(View v, std::basic_string_view> s) @@ -87,18 +91,18 @@ test_illformed_utf16() compare(uc::_Utf16_view(s.substr(0, 1)), r); compare(uc::_Utf16_view(s.substr(1, 1)), r); std::array s2{ s[0], s[0] }; - compare(uc::_Utf16_view(s2), u"\uFFFD\uFFFD"sv); + compare(uc::_Utf16_view(std::span(s2)), u"\uFFFD\uFFFD"sv); std::array s3{ s[0], s[0], s[1] }; - compare(uc::_Utf16_view(s3), u"\uFFFD\N{CLOWN FACE}"sv); + compare(uc::_Utf16_view(std::span(s3)), u"\uFFFD\N{CLOWN FACE}"sv); std::array s4{ s[1], s[0] }; - compare(uc::_Utf16_view(s4), u"\uFFFD\uFFFD"sv); + compare(uc::_Utf16_view(std::span(s4)), u"\uFFFD\uFFFD"sv); std::array s5{ s[1], s[0], s[1] }; - compare(uc::_Utf16_view(s5), u"\uFFFD\N{CLOWN FACE}"sv); + compare(uc::_Utf16_view(std::span(s5)), u"\uFFFD\N{CLOWN FACE}"sv); std::array s6{ 0xDC00, 0xDC01 }; - compare(uc::_Utf16_view(s6), u"\uFFFD\uFFFD"sv); + compare(uc::_Utf16_view(std::span(s6)), u"\uFFFD\uFFFD"sv); std::array s7{ 0xD7FF, 0xDC00 }; - compare(uc::_Utf16_view(s7), u"\uD7FF\uFFFD"sv); + compare(uc::_Utf16_view(std::span(s7)), u"\uD7FF\uFFFD"sv); } constexpr void