From 7f25ede888e85ca037b6593cd3edd024506de469 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Jan 2024 10:27:15 +0100 Subject: [PATCH] net/AddressInfo: add method Cast() --- src/net/AddressInfo.hxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/net/AddressInfo.hxx b/src/net/AddressInfo.hxx index c53a7e343..d99925715 100644 --- a/src/net/AddressInfo.hxx +++ b/src/net/AddressInfo.hxx @@ -55,6 +55,13 @@ public: constexpr operator SocketAddress() const noexcept { return {ai_addr, (SocketAddress::size_type)ai_addrlen}; } + + /** + * Cast a #addrinfo reference to an #AddressInfo reference. + */ + static constexpr const AddressInfo &Cast(const struct addrinfo &ai) noexcept { + return static_cast(ai); + } }; class AddressInfoList {