diff --git a/src/net/StaticSocketAddress.hxx b/src/net/StaticSocketAddress.hxx index b7b3f2c73..a5f1ca17d 100644 --- a/src/net/StaticSocketAddress.hxx +++ b/src/net/StaticSocketAddress.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef STATIC_SOCKET_ADDRESS_HXX -#define STATIC_SOCKET_ADDRESS_HXX +#pragma once #include "SocketAddress.hxx" // IWYU pragma: export #include "Features.hxx" @@ -24,7 +23,7 @@ private: struct sockaddr_storage address; public: - StaticSocketAddress() = default; + constexpr StaticSocketAddress() noexcept = default; explicit StaticSocketAddress(SocketAddress src) noexcept { *this = src; @@ -61,11 +60,11 @@ public: return sizeof(address); } - size_type GetSize() const noexcept { + constexpr size_type GetSize() const noexcept { return size; } - void SetSize(size_type _size) noexcept { + constexpr void SetSize(size_type _size) noexcept { assert(_size > 0); assert(size_t(_size) <= sizeof(address)); @@ -75,19 +74,19 @@ public: /** * Set the size to the maximum value for this class. */ - void SetMaxSize() { + constexpr void SetMaxSize() { SetSize(GetCapacity()); } - int GetFamily() const noexcept { + constexpr int GetFamily() const noexcept { return address.ss_family; } - bool IsDefined() const noexcept { + constexpr bool IsDefined() const noexcept { return GetFamily() != AF_UNSPEC; } - void Clear() noexcept { + constexpr void Clear() noexcept { size = sizeof(address.ss_family); address.ss_family = AF_UNSPEC; } @@ -130,5 +129,3 @@ public: return !(*this == other); } }; - -#endif