inline void
println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args)
{
- std::print(__os, "{}\n",
- std::format(__fmt, std::forward<_Args>(__args)...));
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 4088. println ignores the locale imbued in std::ostream
+ std::print(__os, "{}\n", std::format(__os.getloc(), __fmt,
+ std::forward<_Args>(__args)...));
}
// Defined for C++26, supported as an extension to C++23.
// { dg-output "garbage in . garbage out" }
}
-struct brit_punc : std::numpunct<char>
-{
- std::string do_grouping() const override { return "\3\3"; }
- char do_thousands_sep() const override { return ','; }
- std::string do_truename() const override { return "yes mate"; }
- std::string do_falsename() const override { return "nah bruv"; }
-};
-
void
test_locale()
{
// The default C locale.
std::locale cloc = std::locale::classic();
- // A custom locale using comma digit separators.
+ // A custom locale using tilde digit separators.
std::locale bloc(cloc, new stream_punc);
{
std::print(os, "{:L} {}", 12345, 6789);
VERIFY(os.str() == "1~23~45 6789");
}
+
+ {
+ // LWG 4088. println ignores the locale imbued in std::ostream
+ std::ostringstream os;
+ os.imbue(bloc);
+ std::println(os, "{:L} {}", 12345, 6789);
+ VERIFY(os.str() == "1~23~45 6789\n");
+ }
}
void