From 1081ecdae80d10bcac0f8543d665c5579f271e61 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 25 Apr 2012 14:29:50 -0400 Subject: Fixed non-debug build --- include/anope.h | 22 +++++++++++++++++----- include/extensible.h | 2 +- include/modes.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/anope.h b/include/anope.h index c67b1decb..a5056d50c 100644 --- a/include/anope.h +++ b/include/anope.h @@ -596,25 +596,37 @@ template inline T convertTo(const Anope::string &s, bool failIfLefto return x; } -/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast - * for debug builds and static_cast on releass builds to speed up the program - * because dynamic_cast relies on RTTI. +/** Casts to be used instead of dynamic_cast, this uses dynamic_cast + * for debug builds and static_cast/reinterpret_cast on releass builds + * to speed up the program because dynamic_cast relies on RTTI. */ #ifdef DEBUG_BUILD # include #endif -template inline T debug_cast(O ptr) +template inline T anope_dynamic_static_cast(O ptr) { #ifdef DEBUG_BUILD T ret = dynamic_cast(ptr); if (ptr != NULL && ret == NULL) - throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); + throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); return ret; #else return static_cast(ptr); #endif } +template inline T anope_dynamic_reinterpret_cast(O ptr) +{ +#ifdef DEBUG_BUILD + T ret = dynamic_cast(ptr); + if (ptr != NULL && ret == NULL) + throw CoreException(Anope::string("anope_dynamic_reinterpret_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); + return ret; +#else + return reinterpret_cast(ptr); +#endif +} + /*************************************************************************/ /** Class with the ability to keep flags on items, they should extend from this diff --git a/include/extensible.h b/include/extensible.h index e0281c197..6e6d42fb7 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -90,7 +90,7 @@ class CoreExport Extensible { extensible_map::const_iterator it = this->extension_items.find(key); if (it != this->extension_items.end()) - return debug_cast(it->second); + return anope_dynamic_static_cast(it->second); return NULL; } diff --git a/include/modes.h b/include/modes.h index 0fb822b7e..52545d1b9 100644 --- a/include/modes.h +++ b/include/modes.h @@ -113,7 +113,7 @@ enum ModeClass /** This class is the basis of all modes in Anope */ -class CoreExport Mode : public virtual Base +class CoreExport Mode : public Base { public: /* Class of mode this is */ -- cgit