lib/fmt/SocketAddressFormatter: un-inline to reduce header dependencies
This commit is contained in:
parent
df2be0a75f
commit
3f638eeed6
|
@ -0,0 +1,12 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
// author: Max Kellermann <max.kellermann@gmail.com>
|
||||
|
||||
#include "SocketAddressFormatter.hxx"
|
||||
#include "net/ToString.hxx"
|
||||
|
||||
auto
|
||||
fmt::formatter<SocketAddress>::format(SocketAddress address, format_context &ctx)
|
||||
-> format_context::iterator
|
||||
{
|
||||
return formatter<string_view>::format(ToString(address), ctx);
|
||||
}
|
|
@ -4,17 +4,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "net/SocketAddress.hxx"
|
||||
#include "net/ToString.hxx"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <concepts>
|
||||
|
||||
template<std::convertible_to<SocketAddress> T>
|
||||
struct fmt::formatter<T> : formatter<string_view>
|
||||
template<>
|
||||
struct fmt::formatter<SocketAddress> : formatter<string_view>
|
||||
{
|
||||
auto format(SocketAddress address, format_context &ctx) -> format_context::iterator;
|
||||
};
|
||||
|
||||
template<std::convertible_to<SocketAddress> T>
|
||||
struct fmt::formatter<T> : formatter<SocketAddress>
|
||||
{
|
||||
template<typename FormatContext>
|
||||
auto format(SocketAddress address, FormatContext &ctx) {
|
||||
return formatter<string_view>::format(ToString(address), ctx);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@ endif
|
|||
fmt = static_library(
|
||||
'fmt',
|
||||
'RuntimeError.cxx',
|
||||
'SocketAddressFormatter.cxx',
|
||||
'SystemError.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: libfmt,
|
||||
|
|
Loading…
Reference in New Issue