From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 00E6C3858D33; Wed, 17 Jan 2024 12:11:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00E6C3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705493494; bh=d8O67Je4g1EzR7TvgxzrxEwBEvUl7qlHLSOVBCQIvM4=; h=From:To:Subject:Date:From; b=FshAyrBKM3vj3edCFOLdd7TqZuqn54mUGT+d183Pp2gU4ZkH/qWdSELJ3cpPR6IjU jYbariCbcofYsG8UKJG4eNThhUovww6OzqYHHf+LI9z2HhXsH3VoWj4loT+lZ1bSm4 CHZdJe1yLjcQKs5EnPI5ZYT3oop+dkyU9i+ghSZc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-8181] libstdc++: Do not use CTAD for _Utf32_view alias template X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 3fd32d3d22d86ab732b9b997bdabe449b8c53bbe X-Git-Newrev: 665a3ff1539ce24e1215e52a14450ecd9a26e87f Message-Id: <20240117121134.00E6C3858D33@sourceware.org> Date: Wed, 17 Jan 2024 12:11:33 +0000 (GMT) List-Id: https://gcc.gnu.org/g:665a3ff1539ce24e1215e52a14450ecd9a26e87f commit r14-8181-g665a3ff1539ce24e1215e52a14450ecd9a26e87f Author: Jonathan Wakely Date: Tue Jan 16 17:15:26 2024 +0000 libstdc++: Do not use CTAD for _Utf32_view alias template We were relying on P1814R0 (CTAD for alias templates) which isn't supported by Clang. We can just not use CTAD and provide an explicit template argument list for _Utf32_view. Ideally we'd define a deduction guide for _Grapheme_cluster_view that uses views::all_t to properly convert non-views to views, but all_t is defined in and we don't want to include all of that in . So just make it require a view for now, which can be cheaply copied. Although it's not needed yet, it would also be more correct to specialize enable_borrowed_range for the views in . libstdc++-v3/ChangeLog: * include/bits/unicode.h (_Grapheme_cluster_view): Require view. Do not use CTAD for _Utf32_view. (__format_width, __truncate): Do not use CTAD. (enable_borrowed_range<_Utf_view>): Define specialization. (enable_borrowed_range<_Grapheme_cluster_view>): Likewise. Diff: --- libstdc++-v3/include/bits/unicode.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/unicode.h b/libstdc++-v3/include/bits/unicode.h index f1b2b359bdf..d35c83d0090 100644 --- a/libstdc++-v3/include/bits/unicode.h +++ b/libstdc++-v3/include/bits/unicode.h @@ -714,15 +714,15 @@ inline namespace __v15_1_0 }; // Split a range into extended grapheme clusters. - template + template requires ranges::view<_View> class _Grapheme_cluster_view : public ranges::view_interface<_Grapheme_cluster_view<_View>> { public: constexpr - _Grapheme_cluster_view(const _View& __v) - : _M_begin(_Utf32_view(__v).begin()) + _Grapheme_cluster_view(_View __v) + : _M_begin(_Utf32_view<_View>(std::move(__v)).begin()) { } constexpr auto begin() const { return _M_begin; } @@ -946,7 +946,7 @@ inline namespace __v15_1_0 { if (__s.empty()) [[unlikely]] return 0; - _Grapheme_cluster_view __gc(__s); + _Grapheme_cluster_view> __gc(__s); auto __it = __gc.begin(); const auto __end = __gc.end(); size_t __n = __it.width(); @@ -964,7 +964,7 @@ inline namespace __v15_1_0 if (__s.empty()) [[unlikely]] return 0; - _Grapheme_cluster_view __gc(__s); + _Grapheme_cluster_view> __gc(__s); auto __it = __gc.begin(); const auto __end = __gc.end(); size_t __n = __it.width(); @@ -1058,6 +1058,19 @@ inline namespace __v15_1_0 } // namespace __unicode +namespace ranges +{ + template + inline constexpr bool + enable_borrowed_range> + = enable_borrowed_range<_Range>; + + template + inline constexpr bool + enable_borrowed_range> + = enable_borrowed_range<_Range>; +} // namespace ranges + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++20