From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 634DB386076A for ; Fri, 18 Aug 2023 08:44:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 634DB386076A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692348281; 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: in-reply-to:in-reply-to:references:references; bh=E0e2yZY0TVvRvDo7Tktn0dZFYkm0l8gZX63ZjTRCuXo=; b=SwBbZohRMs9NJv3iZl4ZZ4QXcqS+dB+07Q1EIlX2rhg1Prnm1FHYxZ63eKPrnnlPnI1bic 4lTZCo3mforJDijy81kK1CkDF2wYTXFcbX6yXYL1HiyRV694fyhcGOE3IrsJ40NCoh2hRK UG4jHEWGnNywkcM/yB8BdWgPOjLS1ms= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-u4IzU49tOECBE-XunkSJ3Q-1; Fri, 18 Aug 2023 04:44:37 -0400 X-MC-Unique: u4IzU49tOECBE-XunkSJ3Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7753F85CCE1; Fri, 18 Aug 2023 08:44:37 +0000 (UTC) Received: from localhost (unknown [10.42.28.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32F7940C207B; Fri, 18 Aug 2023 08:44:37 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix incomplete rework of wchar_t support in std::format Date: Fri, 18 Aug 2023 09:44:16 +0100 Message-ID: <20230818084437.1297460-1-jwakely@redhat.com> In-Reply-To: <20230817203118.1131359-1-jwakely@redhat.com> References: <20230817203118.1131359-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- r14-3300-g023a62b77f999b left make_wformat_args and some uses of std::wformat_context unguarded by _GLIBCXX_USE_WCHAR_T. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (operator<<): Use __format_context. * include/std/format (__format::__format_context): New alias template. [!_GLIBCXX_USE_WCHAR_T] (wformat_args, make_wformat_arg): Disable. --- libstdc++-v3/include/bits/chrono_io.h | 15 +++++---------- libstdc++-v3/include/std/format | 13 +++++++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index 05caa64fb7c..e16302baf84 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -2263,8 +2263,7 @@ namespace __detail inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const day& __d) { - using _Ctx = __conditional_t, - format_context, wformat_context>; + using _Ctx = __format::__format_context<_CharT>; using _Str = basic_string_view<_CharT>; _Str __s = _GLIBCXX_WIDEN("{:02d} is not a valid day"); if (__d.ok()) @@ -2291,8 +2290,7 @@ namespace __detail inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const month& __m) { - using _Ctx = __conditional_t, - format_context, wformat_context>; + using _Ctx = __format::__format_context<_CharT>; using _Str = basic_string_view<_CharT>; _Str __s = _GLIBCXX_WIDEN("{:L%b}{} is not a valid month"); if (__m.ok()) @@ -2322,8 +2320,7 @@ namespace __detail inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const year& __y) { - using _Ctx = __conditional_t, - format_context, wformat_context>; + using _Ctx = __format::__format_context<_CharT>; using _Str = basic_string_view<_CharT>; _Str __s = _GLIBCXX_WIDEN("-{:04d} is not a valid year"); if (__y.ok()) @@ -2355,8 +2352,7 @@ namespace __detail inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday& __wd) { - using _Ctx = __conditional_t, - format_context, wformat_context>; + using _Ctx = __format::__format_context<_CharT>; using _Str = basic_string_view<_CharT>; _Str __s = _GLIBCXX_WIDEN("{:L%a}{} is not a valid weekday"); if (__wd.ok()) @@ -2544,8 +2540,7 @@ namespace __detail operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_day& __ymd) { - using _Ctx = __conditional_t, - format_context, wformat_context>; + using _Ctx = __format::__format_context<_CharT>; using _Str = basic_string_view<_CharT>; _Str __s = _GLIBCXX_WIDEN("{:%F} is not a valid date"); __os << std::vformat(__ymd.ok() ? __s.substr(0, 5) : __s, diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 13f700a10bf..0b1ae8201af 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -74,20 +74,23 @@ namespace __format // Output iterator that writes to a type-erase character sink. template class _Sink_iter; + + template + using __format_context = basic_format_context<_Sink_iter<_CharT>, _CharT>; } // namespace __format /// @endcond - using format_context - = basic_format_context<__format::_Sink_iter, char>; + using format_context = __format::__format_context; #ifdef _GLIBCXX_USE_WCHAR_T - using wformat_context - = basic_format_context<__format::_Sink_iter, wchar_t>; + using wformat_context = __format::__format_context; #endif // [format.args], class template basic_format_args template class basic_format_args; using format_args = basic_format_args; +#ifdef _GLIBCXX_USE_WCHAR_T using wformat_args = basic_format_args; +#endif // [format.arguments], arguments // [format.arg], class template basic_format_arg @@ -3505,12 +3508,14 @@ namespace __format return _Store(__fmt_args...); } +#ifdef _GLIBCXX_USE_WCHAR_T /// Capture formatting arguments for use by `std::vformat` (for wide output). template [[nodiscard,__gnu__::__always_inline__]] inline auto make_wformat_args(_Args&&... __args) noexcept { return std::make_format_args(__args...); } +#endif /// @cond undocumented namespace __format -- 2.41.0