public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-3320] libstdc++: Fix incomplete rework of wchar_t support in std::format Date: Fri, 18 Aug 2023 08:43:21 +0000 (GMT) [thread overview] Message-ID: <20230818084321.98C6D3858401@sourceware.org> (raw) https://gcc.gnu.org/g:7f8d730a563983187edb563c673d184d5bae8cf1 commit r14-3320-g7f8d730a563983187edb563c673d184d5bae8cf1 Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Aug 18 09:33:23 2023 +0100 libstdc++: Fix incomplete rework of wchar_t support in std::format 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. Diff: --- 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 05caa64fb7c1..e16302baf848 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<is_same_v<_CharT, char>, - 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<is_same_v<_CharT, char>, - 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<is_same_v<_CharT, char>, - 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<is_same_v<_CharT, char>, - 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<is_same_v<_CharT, char>, - 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 13f700a10bfc..0b1ae8201af4 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<typename _CharT> class _Sink_iter; + + template<typename _CharT> + using __format_context = basic_format_context<_Sink_iter<_CharT>, _CharT>; } // namespace __format /// @endcond - using format_context - = basic_format_context<__format::_Sink_iter<char>, char>; + using format_context = __format::__format_context<char>; #ifdef _GLIBCXX_USE_WCHAR_T - using wformat_context - = basic_format_context<__format::_Sink_iter<wchar_t>, wchar_t>; + using wformat_context = __format::__format_context<wchar_t>; #endif // [format.args], class template basic_format_args template<typename _Context> class basic_format_args; using format_args = basic_format_args<format_context>; +#ifdef _GLIBCXX_USE_WCHAR_T using wformat_args = basic_format_args<wformat_context>; +#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<typename... _Args> [[nodiscard,__gnu__::__always_inline__]] inline auto make_wformat_args(_Args&&... __args) noexcept { return std::make_format_args<wformat_context>(__args...); } +#endif /// @cond undocumented namespace __format
reply other threads:[~2023-08-18 8:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230818084321.98C6D3858401@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).