lib/fmt/PathFormatter: eliminate AllocatedPath specialization with std::convertible_to<Path>

This commit is contained in:
Max Kellermann 2024-04-16 10:59:45 +02:00
parent 7a4743d00e
commit 7198db758d

View File

@ -1,24 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project // Copyright The Music Player Daemon Project
#ifndef PATH_FORMATTER_HXX #pragma once
#define PATH_FORMATTER_HXX
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include <fmt/format.h> #include <fmt/format.h>
template<> #include <concepts>
struct fmt::formatter<Path> : formatter<string_view>
template<std::convertible_to<Path> T>
struct fmt::formatter<T> : formatter<string_view>
{ {
template<typename FormatContext> template<typename FormatContext>
auto format(Path path, FormatContext &ctx) { auto format(Path path, FormatContext &ctx) {
return formatter<string_view>::format(path.ToUTF8(), ctx); return formatter<string_view>::format(path.ToUTF8(), ctx);
} }
}; };
template<>
struct fmt::formatter<AllocatedPath> : formatter<Path> {};
#endif