From 3f638eeed6e304b5b016170ba9fcf234df9d806b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jul 2024 09:49:21 +0200 Subject: [PATCH] lib/fmt/SocketAddressFormatter: un-inline to reduce header dependencies --- src/lib/fmt/SocketAddressFormatter.cxx | 12 ++++++++++++ src/lib/fmt/SocketAddressFormatter.hxx | 15 ++++++++------- src/lib/fmt/meson.build | 1 + 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/lib/fmt/SocketAddressFormatter.cxx diff --git a/src/lib/fmt/SocketAddressFormatter.cxx b/src/lib/fmt/SocketAddressFormatter.cxx new file mode 100644 index 000000000..bd31f969c --- /dev/null +++ b/src/lib/fmt/SocketAddressFormatter.cxx @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: BSD-2-Clause +// author: Max Kellermann + +#include "SocketAddressFormatter.hxx" +#include "net/ToString.hxx" + +auto +fmt::formatter::format(SocketAddress address, format_context &ctx) + -> format_context::iterator +{ + return formatter::format(ToString(address), ctx); +} diff --git a/src/lib/fmt/SocketAddressFormatter.hxx b/src/lib/fmt/SocketAddressFormatter.hxx index 7a13bfce4..7020d9083 100644 --- a/src/lib/fmt/SocketAddressFormatter.hxx +++ b/src/lib/fmt/SocketAddressFormatter.hxx @@ -4,17 +4,18 @@ #pragma once #include "net/SocketAddress.hxx" -#include "net/ToString.hxx" #include #include -template T> -struct fmt::formatter : formatter +template<> +struct fmt::formatter : formatter +{ + auto format(SocketAddress address, format_context &ctx) -> format_context::iterator; +}; + +template T> +struct fmt::formatter : formatter { - template - auto format(SocketAddress address, FormatContext &ctx) { - return formatter::format(ToString(address), ctx); - } }; diff --git a/src/lib/fmt/meson.build b/src/lib/fmt/meson.build index f6b0243ee..b0237fd0a 100644 --- a/src/lib/fmt/meson.build +++ b/src/lib/fmt/meson.build @@ -11,6 +11,7 @@ endif fmt = static_library( 'fmt', 'RuntimeError.cxx', + 'SocketAddressFormatter.cxx', 'SystemError.cxx', include_directories: inc, dependencies: libfmt,