Skip to content

Commit

Permalink
Fix formatting of named arguments with locale
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Dec 15, 2022
1 parent d072f1d commit b908954
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -4306,7 +4306,7 @@ template <typename Locale, typename... T,
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
inline auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
-> std::string {
return vformat(loc, string_view(fmt), fmt::make_format_args(args...));
return fmt::vformat(loc, string_view(fmt), fmt::make_format_args(args...));
}

template <typename OutputIt, typename Locale,
Expand Down
5 changes: 5 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2419,4 +2419,9 @@ TEST(format_test, format_facet_grouping) {
EXPECT_EQ(fmt::format(loc, "{:L}", 1234567890), "1,234,567,89,0");
}

TEST(format_test, format_named_arg_with_locale) {
EXPECT_EQ(fmt::format(std::locale(), "{answer}", fmt::arg("answer", 42)),
"42");
}

#endif // FMT_STATIC_THOUSANDS_SEPARATOR

0 comments on commit b908954

Please sign in to comment.