summaryrefslogtreecommitdiff
path: root/include/anope.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-04-25 14:29:50 -0400
committerAdam <Adam@anope.org>2012-04-25 14:29:50 -0400
commit1081ecdae80d10bcac0f8543d665c5579f271e61 (patch)
tree7b2665bc103c7306b2ec08afc46bac5e7689eb38 /include/anope.h
parent2370c16f1e9d395e47fc8963b1c301dff160c547 (diff)
Fixed non-debug build
Diffstat (limited to 'include/anope.h')
-rw-r--r--include/anope.h22
1 files changed, 17 insertions, 5 deletions
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<typename T> 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 <typeinfo>
#endif
-template<typename T, typename O> inline T debug_cast(O ptr)
+template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
{
#ifdef DEBUG_BUILD
T ret = dynamic_cast<T>(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<T>(ptr);
#endif
}
+template<typename T, typename O> inline T anope_dynamic_reinterpret_cast(O ptr)
+{
+#ifdef DEBUG_BUILD
+ T ret = dynamic_cast<T>(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<T>(ptr);
+#endif
+}
+
/*************************************************************************/
/** Class with the ability to keep flags on items, they should extend from this