From 9c62b0f61aab0bd7234d1593b67a24fd84363055 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 5 Mar 2019 20:49:23 -0800 Subject: [PATCH] ircd::net::hostport: Add complementary boolean conversion. --- include/ircd/net/hostport.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/ircd/net/hostport.h b/include/ircd/net/hostport.h index 7a876a650..c361314cf 100644 --- a/include/ircd/net/hostport.h +++ b/include/ircd/net/hostport.h @@ -58,6 +58,7 @@ struct ircd::net::hostport string_view service {canon_service}; uint16_t port {canon_port}; + explicit operator bool() const; bool operator!() const; hostport(const string_view &host, const string_view &service, const uint16_t &port = canon_port); @@ -130,12 +131,20 @@ ircd::net::hostport::hostport(const string_view &amalgam) } } +inline +ircd::net::hostport::operator +bool() +const +{ + static const hostport defaults{}; + return net::host(*this) != net::host(defaults); +} + inline bool ircd::net::hostport::operator!() const { - static const hostport defaults{}; - return net::host(*this) == net::host(defaults); + return !bool(*this); } inline ircd::string_view &