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
// Copyright The Music Player Daemon Project
#ifndef PATH_FORMATTER_HXX
#define PATH_FORMATTER_HXX
#pragma once
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include <fmt/format.h>
template<>
struct fmt::formatter<Path> : formatter<string_view>
#include <concepts>
template<std::convertible_to<Path> T>
struct fmt::formatter<T> : formatter<string_view>
{
template<typename FormatContext>
auto format(Path path, FormatContext &ctx) {
return formatter<string_view>::format(path.ToUTF8(), ctx);
}
};
template<>
struct fmt::formatter<AllocatedPath> : formatter<Path> {};
#endif