Skip to content

Commit

Permalink
Fix path formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed May 17, 2022
1 parent f0903ad commit 9730fb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
#ifndef FMT_STD_H_
#define FMT_STD_H_

#include <version>
#include "format.h"

#if FMT_HAS_INCLUDE(<version>)
# include <version>
#endif

#ifdef __cpp_lib_filesystem
# include <filesystem>

namespace fmt {

template <> struct formatter<std::filesystem::path> : formatter<string_view> {
template <>
struct fmt::formatter<std::filesystem::path> : formatter<string_view> {
template <typename FormatContext>
auto format(const path& p, FormatContext& ctx) const ->
auto format(const std::filesystem::path& p, FormatContext& ctx) const ->
typename FormatContext::iterator {
return formatter<string_view>::format(p.string(), ctx);
}
};

} // namespace fmt
#endif

#endif // FMT_STD_H_
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ endif()
add_fmt_test(printf-test)
add_fmt_test(ranges-test ranges-odr-test.cc)
add_fmt_test(scan-test)
add_fmt_test(std-test)
add_fmt_test(unicode-test HEADER_ONLY)
if (MSVC)
target_compile_options(unicode-test PRIVATE /utf-8)
Expand Down

0 comments on commit 9730fb0

Please sign in to comment.