diff --git a/include/fmt/std.h b/include/fmt/std.h index 41d2b283..fe1c2c47 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -57,6 +57,7 @@ inline void write_escaped_path( } // namespace detail +#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1920 template struct formatter : formatter> { @@ -69,6 +70,33 @@ struct formatter basic_string_view(quoted.data(), quoted.size()), ctx); } }; +#else +// Workaround for MSVC 2017 and earlier. +template <> +struct formatter + : formatter> { + template + auto format(const std::filesystem::path& p, FormatContext& ctx) const -> + typename FormatContext::iterator { + basic_memory_buffer quoted; + detail::write_escaped_path(quoted, p); + return formatter>::format( + basic_string_view(quoted.data(), quoted.size()), ctx); + } +}; +template <> +struct formatter + : formatter> { + template + auto format(const std::filesystem::path& p, FormatContext& ctx) const -> + typename FormatContext::iterator { + basic_memory_buffer quoted; + detail::write_escaped_path(quoted, p); + return formatter>::format( + basic_string_view(quoted.data(), quoted.size()), ctx); + } +}; +#endif FMT_END_NAMESPACE #endif