Implement println (#3267)

This commit is contained in:
Shawn Zhong
2023-01-24 12:30:00 -08:00
committed by GitHub
parent 9409b2e4d8
commit 87c066a35b
6 changed files with 81 additions and 7 deletions
+30
View File
@@ -3009,6 +3009,36 @@ FMT_INLINE void print(std::FILE* f, format_string<T...> fmt, T&&... args) {
: detail::vprint_mojibake(f, fmt, vargs);
}
/**
\rst
Formats ``args`` according to specifications in ``fmt`` and writes the
output to the file ``f`` followed by a newline.
**Example**::
fmt::println(stderr, "Don't {}!", "panic");
\endrst
*/
template <typename... T>
FMT_INLINE void println(std::FILE* f, format_string<T...> fmt, T&&... args) {
return fmt::print(f, "{}\n", fmt::format(fmt, std::forward<T>(args)...));
}
/**
\rst
Formats ``args`` according to specifications in ``fmt`` and writes the output
to ``stdout`` followed by a newline.
**Example**::
fmt::println("Elapsed time: {0:.2f} seconds", 1.23);
\endrst
*/
template <typename... T>
FMT_INLINE void println(format_string<T...> fmt, T&&... args) {
return fmt::println(stdout, fmt, std::forward<T>(args)...);
}
FMT_MODULE_EXPORT_END
FMT_GCC_PRAGMA("GCC pop_options")
FMT_END_NAMESPACE