lib/fmt/PathFormatter: eliminate AllocatedPath specialization with std::convertible_to<Path>
This commit is contained in:
parent
7a4743d00e
commit
7198db758d
@ -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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user