mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-04 15:40:07 +00:00
Improve std::filesystem::path formatter.
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
4f9311e689
commit
03b1b2838e
@ -19,14 +19,9 @@
|
|||||||
#ifdef __cpp_lib_filesystem
|
#ifdef __cpp_lib_filesystem
|
||||||
# include <filesystem>
|
# include <filesystem>
|
||||||
|
|
||||||
template <>
|
FMT_BEGIN_NAMESPACE
|
||||||
struct fmt::formatter<std::filesystem::path> : formatter<string_view> {
|
template <> struct formatter<std::filesystem::path> : ostream_formatter {};
|
||||||
template <typename FormatContext>
|
FMT_END_NAMESPACE
|
||||||
auto format(const std::filesystem::path& p, FormatContext& ctx) const ->
|
|
||||||
typename FormatContext::iterator {
|
|
||||||
return formatter<string_view>::format(p.string(), ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
TEST(std_test, path) {
|
TEST(std_test, path) {
|
||||||
#ifdef __cpp_lib_filesystem
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user