Commit c629ac71 authored by Max Kellermann's avatar Max Kellermann

net/SocketAddress: add more "noexcept"

parent 0195d559
...@@ -49,7 +49,7 @@ SocketAddress::operator==(SocketAddress other) const noexcept ...@@ -49,7 +49,7 @@ SocketAddress::operator==(SocketAddress other) const noexcept
#ifdef HAVE_TCP #ifdef HAVE_TCP
unsigned unsigned
SocketAddress::GetPort() const SocketAddress::GetPort() const noexcept
{ {
if (IsNull()) if (IsNull())
return 0; return 0;
......
...@@ -59,29 +59,30 @@ private: ...@@ -59,29 +59,30 @@ private:
public: public:
SocketAddress() = default; SocketAddress() = default;
constexpr SocketAddress(std::nullptr_t):address(nullptr), size(0) {} constexpr SocketAddress(std::nullptr_t) noexcept
:address(nullptr), size(0) {}
constexpr SocketAddress(const struct sockaddr *_address, constexpr SocketAddress(const struct sockaddr *_address,
size_type _size) size_type _size) noexcept
:address(_address), size(_size) {} :address(_address), size(_size) {}
static constexpr SocketAddress Null() { static constexpr SocketAddress Null() noexcept {
return nullptr; return nullptr;
} }
constexpr bool IsNull() const { constexpr bool IsNull() const noexcept {
return address == nullptr; return address == nullptr;
} }
const struct sockaddr *GetAddress() const { const struct sockaddr *GetAddress() const noexcept {
return address; return address;
} }
constexpr size_type GetSize() const { constexpr size_type GetSize() const noexcept {
return size; return size;
} }
constexpr int GetFamily() const { constexpr int GetFamily() const noexcept {
return address->sa_family; return address->sa_family;
} }
...@@ -89,7 +90,7 @@ public: ...@@ -89,7 +90,7 @@ public:
* Does the object have a well-defined address? Check !IsNull() * Does the object have a well-defined address? Check !IsNull()
* before calling this method. * before calling this method.
*/ */
bool IsDefined() const { bool IsDefined() const noexcept {
return GetFamily() != AF_UNSPEC; return GetFamily() != AF_UNSPEC;
} }
...@@ -98,7 +99,7 @@ public: ...@@ -98,7 +99,7 @@ public:
* Extract the port number. Returns 0 if not applicable. * Extract the port number. Returns 0 if not applicable.
*/ */
gcc_pure gcc_pure
unsigned GetPort() const; unsigned GetPort() const noexcept;
#endif #endif
gcc_pure gcc_pure
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment