From fea712abb1fcd50e51390cc27441ff2bc63bf23f Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Sun, 7 Oct 2018 15:03:58 +0200 Subject: [PATCH] Parameterize ostream functions on the type of the format string. Signed-off-by: Daniela Engert --- include/fmt/ostream.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index e467f1ae..186a7d84 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -141,16 +141,12 @@ inline void vprint(std::basic_ostream &os, fmt::print(cerr, "Don't {}!", "panic"); \endrst */ -template -inline void print(std::ostream &os, string_view format_str, - const Args & ... args) { - vprint(os, format_str, make_format_args(args...)); -} - -template -inline void print(std::wostream &os, wstring_view format_str, - const Args & ... args) { - vprint(os, format_str, make_format_args(args...)); +template +inline typename std::enable_if::value>::type +print(std::basic_ostream &os, const S &format_str, + const Args & ... args) { + internal::checked_args ca(format_str, args...); + vprint(os, internal::to_string_view(format_str), *ca); } FMT_END_NAMESPACE