diff --git a/beast/net/IPAddress.h b/beast/net/IPAddress.h index a4ff62bc7..e59020a96 100644 --- a/beast/net/IPAddress.h +++ b/beast/net/IPAddress.h @@ -24,8 +24,9 @@ #include #include #include +#include #include - +#include #include #include #include @@ -102,14 +103,14 @@ public: /** Returns `true` if this address represents an IPv4 address. */ bool - is_v4 () const + is_v4 () const noexcept { return m_type == ipv4; } /** Returns `true` if this address represents an IPv6 address. */ bool - is_v6() const + is_v6() const noexcept { return m_type == ipv6; } @@ -121,12 +122,11 @@ public: AddressV4 const& to_v4 () const { - if (m_type != ipv4) + if (!is_v4 ()) throw std::bad_cast(); return m_v4; } - /** Returns the IPv6 address. Precondition: is_v6() == `true` @@ -134,7 +134,7 @@ public: AddressV6 const& to_v6 () const { - if (m_type != ipv6) + if (!is_v6 ()) throw std::bad_cast(); return m_v6; } @@ -142,13 +142,15 @@ public: template friend void - hash_append(Hasher& h, Address const& addr) + hash_append(Hasher& h, Address const& addr) noexcept { using beast::hash_append; if (addr.is_v4 ()) hash_append(h, addr.to_v4 ()); - else + else if (addr.is_v6 ()) hash_append(h, addr.to_v6 ()); + else + assert (false); } /** Arithmetic comparison. */ diff --git a/beast/net/IPAddressV4.h b/beast/net/IPAddressV4.h index 9080d5f4b..5a811c212 100644 --- a/beast/net/IPAddressV4.h +++ b/beast/net/IPAddressV4.h @@ -140,7 +140,7 @@ struct AddressV4 Proxy operator[] (std::size_t index) const; Proxy operator[] (std::size_t index); - /** @{ */ + /** @} */ /** The value as a 32 bit unsigned. */ std::uint32_t value;