From 30de36aefa1bf76a2e95e93a8960a940b6ffb70e Mon Sep 17 00:00:00 2001 From: Daumantas Kavolis <12998363+dkavolis@users.noreply.github.com> Date: Thu, 26 Sep 2019 15:37:14 +0100 Subject: [PATCH] provide print overload for compiled format --- include/fmt/ostream.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 18ae820c..2d6ad7f8 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -128,12 +128,22 @@ void vprint(std::basic_ostream& os, basic_string_view format_str, fmt::print(cerr, "Don't {}!", "panic"); \endrst */ -template ::value, char_t>> +template , + FMT_ENABLE_IF(internal::is_string::value)> void print(std::basic_ostream& os, const S& format_str, Args&&... args) { vprint(os, to_string_view(format_str), {internal::make_args_checked(format_str, args...)}); } + +// fallback print overload for types that define char_t but are not strings +// such as compiled format +template , + FMT_ENABLE_IF(!internal::is_string::value)> +void print(std::basic_ostream& os, const S& format, Args&&... args) { + basic_memory_buffer buffer; + format_to(std::back_inserter(buffer), format, args...); + internal::write(os, buffer); +} FMT_END_NAMESPACE #endif // FMT_OSTREAM_H_