From patchwork Tue Jan 16 21:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 188618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp533231dye; Tue, 16 Jan 2024 13:27:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhR/V7VS7Lf6pUhT7RBXEXzIf6d0hcXXaBGam6vjgjMOuKSrP4xQBs/xoGFhDY/TyK4S4e X-Received: by 2002:a05:6808:1a1a:b0:3bd:937b:6a63 with SMTP id bk26-20020a0568081a1a00b003bd937b6a63mr60651oib.25.1705440454429; Tue, 16 Jan 2024 13:27:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705440454; cv=pass; d=google.com; s=arc-20160816; b=P9++ze3cJoczpWBzw8rsXnlMz2yHi5dXIP6/FFS+3vDLuQgEC7gGyQcaMHUFNEZX10 syGKAoW8nOQNnlCcPbhiVKMv9ANEfbXB/MS+u224m6k8ZaHYuolpQDnpaBFAYf4AAimA fxW+q7NTpvl9A5dc1YHRShGaGTnt+qDvnsPPZWppE5Z5c6YrmYNJbFXb2RqDTK3rKGRg ncMPUz2kauhrHFLAGbdoKkJFtwf4Yz1XRMb0rC9/oPEFNtjREjCt2G8Qpwp0Vt5/Qh78 VipocYQEPsQBMa7eALiX5gYa6C600rCjtbiXyPbTjTvnoxXWBsVec/kafHdU2sLKM4Tz tk2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=TwwayzYp9XpuyKnUy1BvTEyJq8bT0RJaWWrwBMtecVM=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=aWXqxKuwXxaDT3Xe7NK8Txn/Bpmf6t2xBKeMW+79lkr27HlovZ7iwr4hiGo9x6RqnK kH1o9CXKCRRfS62AOZ0nhG3Gnr1Cr+sqYc1Mx18r92LY4Vh0Y7SwCESo5vh3M5Zf7zza TwwSq1On7rVWCrIz3B5BkTuSZnl440obtdMEIliVRLsmsgdDKEw26rnoUZkyPz+fNJI6 lFpbQOy1HT3OK/P6ChZBu9o/J2DL912UIlm9/Ul/xNMQnht/+xxKHSaevdVzTsWwvPO5 8b01JKr6bD2uW0cTDOXKLtS2byp1rpbmmAnc7sddvoWXkgfbdbvJLyczG+Fl41KqVYQK K6mA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RuDRvLwL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x17-20020ac85f11000000b00429aa3a8958si10656110qta.365.2024.01.16.13.27.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 13:27:34 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RuDRvLwL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22A903858C54 for ; Tue, 16 Jan 2024 21:27:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CAB433858D1E for ; Tue, 16 Jan 2024 21:26:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAB433858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CAB433858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705440413; cv=none; b=F86tuele2ICR4ynDLj16aYjbAa01OYpb90J5X8QN1I7WFskk9jW5ruWlCuGyn4Utv5jDPk/sNvJgfd3SfhIINwfMeEbZHbwMoi68BpP5xgDreCI2698nG08WZjgel9tnEzzUBsK9eslJKotZkeQcc8KuJSW418jFwBYNRXoz4uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705440413; c=relaxed/simple; bh=jU6kJKViufM7C6LpMvls5hQDQhH7xzOYEGDVsXYUaoU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TwDOroJ/pPxS5HCCuzXj4u41IF3E+A7RpMnbgAsQW2QBT4uhPn67EvQehM4f0uhpfiT0uB7p9uMjCrIYhXxOzhLi47H84ClquUcTH9fkU3tiY+kp41B2DKbXADrkd3JEbiOCDiymDmV/R8s4hyyiI9V8wmRSGSx8A+b+hMstJsM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705440411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TwwayzYp9XpuyKnUy1BvTEyJq8bT0RJaWWrwBMtecVM=; b=RuDRvLwLYnWrWlOtZICokp1ehcomAG2mBFp+ZrYcnUOP/E1P/Wm1gF5WI4d0nMwZ2H6w1W 0WReUQys7gEK8Vb2guwtYjUVJZFCpHXUfyzw6vY2fUR6mOT9cX1koZe0Tqna8VQXcUb3jN 9Bo8hkTIJJf9AkEmq+U94CNctTWx8K4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-zk8EzNsHMqKoKppVt0CpLQ-1; Tue, 16 Jan 2024 16:26:48 -0500 X-MC-Unique: zk8EzNsHMqKoKppVt0CpLQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77C3385A588; Tue, 16 Jan 2024 21:26:48 +0000 (UTC) Received: from localhost (unknown [10.42.28.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4477340C6EB9; Tue, 16 Jan 2024 21:26:48 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Do not use CTAD for _Utf32_view alias template Date: Tue, 16 Jan 2024 21:21:52 +0000 Message-ID: <20240116212646.1717827-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788283929701810832 X-GMAIL-MSGID: 1788283929701810832 Tested aarch64-linux. I plan to push this to fix an error when using trunk with Clang. -- >8 -- 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. --- 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