diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index e16302baf8487c0d22b0d32d3e39c34a29794aea..d558802e7d8662c4cd16da9c407a9f2d854c4d53 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -2390,15 +2390,14 @@ namespace __detail __os2.imbue(__os.getloc()); __os2 << __wdi.weekday(); const auto __i = __wdi.index(); - if constexpr (is_same_v<_CharT, char>) - __os2 << std::format("[{}", __i); - else - __os2 << std::format(L"[{}", __i); - basic_string_view<_CharT> __s = _GLIBCXX_WIDEN(" is not a valid index]"); + basic_string_view<_CharT> __s + = _GLIBCXX_WIDEN("[ is not a valid index]"); + __os2 << __s[0]; + __os2 << std::format(_GLIBCXX_WIDEN("{}"), __i); if (__i >= 1 && __i <= 5) __os2 << __s.back(); else - __os2 << __s; + __os2 << __s.substr(1); __os << __os2.view(); return __os; } @@ -2457,11 +2456,7 @@ namespace __detail // As above, just write straight to a stringstream, as if by "{:L}/last" basic_stringstream<_CharT> __os2; __os2.imbue(__os.getloc()); - __os2 << __mdl.month(); - if constexpr (is_same_v<_CharT, char>) - __os2 << "/last"; - else - __os2 << L"/last"; + __os2 << __mdl.month() << _GLIBCXX_WIDEN("/last"); __os << __os2.view(); return __os; } diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 0b1ae8201af4a653b2c41e488984656e7e53f96e..648f847ad9692f1a84131dd63cc6089bfd287685 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -1142,13 +1142,15 @@ namespace __format basic_string_view<_CharT> __str; if constexpr (is_same_v<char, _CharT>) __str = __narrow_str; +#ifdef _GLIBCXX_USE_WCHAR_T else { size_t __n = __narrow_str.size(); auto __p = (_CharT*)__builtin_alloca(__n * sizeof(_CharT)); - __to_wstring_numeric(__narrow_str.data(), __n, __p); + std::__to_wstring_numeric(__narrow_str.data(), __n, __p); __str = {__p, __n}; } +#endif if (_M_spec._M_localized) { @@ -1624,11 +1626,13 @@ namespace __format basic_string_view<_CharT> __str; if constexpr (is_same_v<_CharT, char>) __str = __narrow_str; +#ifdef _GLIBCXX_USE_WCHAR_T else { __wstr = std::__to_wstring_numeric(__narrow_str); __str = __wstr; } +#endif if (_M_spec._M_localized) { @@ -2290,12 +2294,14 @@ namespace __format basic_string_view<_CharT> __str; if constexpr (is_same_v<_CharT, char>) __str = string_view(__buf, __n); +#ifdef _GLIBCXX_USE_WCHAR_T else { auto __p = (_CharT*)__builtin_alloca(__n * sizeof(_CharT)); - __to_wstring_numeric(__buf, __n, __p); + std::__to_wstring_numeric(__buf, __n, __p); __str = wstring_view(__p, __n); } +#endif #if _GLIBCXX_P2518R3 if (_M_spec._M_zero_fill)