From 03b1b2838ea740e73172c77b9641c3607f03df5a Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Wed, 18 May 2022 18:04:47 +0500 Subject: [PATCH] Improve std::filesystem::path formatter. Signed-off-by: Vladislav Shchapov --- include/fmt/std.h | 11 +++-------- test/std-test.cc | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/fmt/std.h b/include/fmt/std.h index baa30e1f..2a75d8ff 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -19,14 +19,9 @@ #ifdef __cpp_lib_filesystem # include -template <> -struct fmt::formatter : formatter { - template - auto format(const std::filesystem::path& p, FormatContext& ctx) const -> - typename FormatContext::iterator { - return formatter::format(p.string(), ctx); - } -}; +FMT_BEGIN_NAMESPACE +template <> struct formatter : ostream_formatter {}; +FMT_END_NAMESPACE #endif FMT_BEGIN_NAMESPACE diff --git a/test/std-test.cc b/test/std-test.cc index 6cda2891..dcd75d5f 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -11,7 +11,7 @@ TEST(std_test, path) { #ifdef __cpp_lib_filesystem - EXPECT_EQ(fmt::format("{:8}", std::filesystem::path("foo")), "foo "); + EXPECT_EQ(fmt::format("{:8}", std::filesystem::path("foo")), "\"foo\" "); #endif }