From f7c326dbebde7fce3a21b18c6fb6758b782d8c9f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 30 Jan 2020 16:51:18 +0100 Subject: [PATCH] net/StaticSocketAddress: make the cast operators `constexpr` --- src/net/StaticSocketAddress.hxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/net/StaticSocketAddress.hxx b/src/net/StaticSocketAddress.hxx index 7a5d0a218..e6f7572dd 100644 --- a/src/net/StaticSocketAddress.hxx +++ b/src/net/StaticSocketAddress.hxx @@ -54,17 +54,16 @@ public: StaticSocketAddress &operator=(SocketAddress other) noexcept; - operator SocketAddress() const noexcept { - return SocketAddress(reinterpret_cast(&address), - size); + constexpr operator SocketAddress() const noexcept { + return SocketAddress(*this, size); } - operator struct sockaddr *() noexcept { - return reinterpret_cast(&address); + constexpr operator struct sockaddr *() noexcept { + return (struct sockaddr *)(void *)&address; } - operator const struct sockaddr *() const noexcept { - return reinterpret_cast(&address); + constexpr operator const struct sockaddr *() const noexcept { + return (const struct sockaddr *)(const void *)&address; } constexpr size_type GetCapacity() const noexcept {