From fc429d18b6d3c7587ae66cce27504871d4f49962 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 11 Apr 2022 16:52:34 -0700 Subject: [PATCH] Avoid overhead on sensible platforms --- include/fmt/ostream.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index b35725a3..b77bd9a7 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -93,8 +93,9 @@ inline bool write(std::wfilebuf&, fmt::basic_string_view) { // It is a separate function rather than a part of vprint to simplify testing. template void write_buffer(std::basic_ostream& os, buffer& buf) { - if (auto filebuf = dynamic_cast*>(os.rdbuf())) { - if (write(*filebuf, {buf.data(), buf.size()})) return; + if (FMT_MSC_VER) { + auto filebuf = dynamic_cast*>(os.rdbuf()); + if (filebuf && write(*filebuf, {buf.data(), buf.size()})) return; } const Char* buf_data = buf.data(); using unsigned_streamsize = std::make_unsigned::type;