lib/fmt/SocketAddressFormatter: un-inline to reduce header dependencies

This commit is contained in:
Max Kellermann 2024-07-02 09:49:21 +02:00 committed by Max Kellermann
parent df2be0a75f
commit 3f638eeed6
3 changed files with 21 additions and 7 deletions

View File

@ -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);
}

View File

@ -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);
}
};

View File

@ -11,6 +11,7 @@ endif
fmt = static_library(
'fmt',
'RuntimeError.cxx',
'SocketAddressFormatter.cxx',
'SystemError.cxx',
include_directories: inc,
dependencies: libfmt,