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<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 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<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 -- 2.41.0