net/AddressInfo: add method Cast()

This commit is contained in:
Max Kellermann 2024-01-08 10:27:15 +01:00 committed by Max Kellermann
parent 4a2fff019a
commit 7f25ede888
1 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,13 @@ public:
constexpr operator SocketAddress() const noexcept { constexpr operator SocketAddress() const noexcept {
return {ai_addr, (SocketAddress::size_type)ai_addrlen}; 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<const AddressInfo &>(ai);
}
}; };
class AddressInfoList { class AddressInfoList {