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: 84213 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9001E3858C60 for ; Tue, 16 Jan 2024 21:27:20 +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+patchwork=sourceware.org@gcc.gnu.org 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