lib/fmt/SocketAddressFormatter: switch to the new net/FormatAddress library

This commit is contained in:
Max Kellermann 2024-07-05 18:38:52 +02:00
parent d3ef4ab234
commit 8790f2469c
1 changed files with 10 additions and 2 deletions

View File

@ -2,11 +2,19 @@
// author: Max Kellermann <max.kellermann@gmail.com>
#include "SocketAddressFormatter.hxx"
#include "net/ToString.hxx"
#include "net/FormatAddress.hxx"
auto
fmt::formatter<SocketAddress>::format(SocketAddress address, format_context &ctx) const
-> format_context::iterator
{
return formatter<string_view>::format(ToString(address), ctx);
char buffer[256];
std::string_view s;
if (ToString(std::span{buffer}, address))
s = buffer;
else
s = "?";
return formatter<string_view>::format(s, ctx);
}