lib/fmt/SocketAddressFormatter: un-inline to reduce header dependencies
This commit is contained in:
parent
df2be0a75f
commit
3f638eeed6
12
src/lib/fmt/SocketAddressFormatter.cxx
Normal file
12
src/lib/fmt/SocketAddressFormatter.cxx
Normal 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);
|
||||||
|
}
|
@ -4,17 +4,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "net/SocketAddress.hxx"
|
#include "net/SocketAddress.hxx"
|
||||||
#include "net/ToString.hxx"
|
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
template<std::convertible_to<SocketAddress> T>
|
template<>
|
||||||
struct fmt::formatter<T> : formatter<string_view>
|
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 = static_library(
|
||||||
'fmt',
|
'fmt',
|
||||||
'RuntimeError.cxx',
|
'RuntimeError.cxx',
|
||||||
|
'SocketAddressFormatter.cxx',
|
||||||
'SystemError.cxx',
|
'SystemError.cxx',
|
||||||
include_directories: inc,
|
include_directories: inc,
|
||||||
dependencies: libfmt,
|
dependencies: libfmt,
|
||||||
|
Loading…
Reference in New Issue
Block a user