From 8f96cfc20a92f00e5b87969d589c4ec360020366 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 28 Jun 2017 09:00:29 +0100 Subject: Remove typeid use in network_address Since I had to add an ID to the derived classes anyway, this can be used instead. This removes an apparently pointless warning from CLANG too. --- contrib/epee/include/net/net_utils_base.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'contrib/epee') diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index 1884412dc..3bea11985 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -115,10 +115,9 @@ namespace net_utils std::string host_str() const { return (*this) ? (*this)->host_str() : ""; } bool is_loopback() const { return (*this)->is_loopback(); } bool is_local() const { return (*this)->is_local(); } - const std::type_info &type() const { return typeid(**this); } uint8_t get_type_id() const { return (*this)->get_type_id(); } - template Type &as() { if (type() != typeid(Type)) throw std::runtime_error("Bad type"); return *(Type*)get(); } - template const Type &as() const { if (type() != typeid(Type)) throw std::runtime_error("Bad type"); return *(const Type*)get(); } + template Type &as() { if (get_type_id() != Type::ID) throw std::runtime_error("Bad type"); return *(Type*)get(); } + template const Type &as() const { if (get_type_id() != Type::ID) throw std::runtime_error("Bad type"); return *(const Type*)get(); } BEGIN_KV_SERIALIZE_MAP() uint8_t type = is_store ? this_ref.get_type_id() : 0; -- cgit v1.2.3