public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3320] libstdc++: Fix incomplete rework of wchar_t support in std::format
@ 2023-08-18 8:43 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-08-18 8:43 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-18 8:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 8:43 [gcc r14-3320] libstdc++: Fix incomplete rework of wchar_t support in std::format Jonathan Wakely
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).