diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/access.h | 4 | ||||
| -rw-r--r-- | include/anope.h | 24 |
2 files changed, 21 insertions, 7 deletions
diff --git a/include/access.h b/include/access.h index 19b6b3b02..cb24a6030 100644 --- a/include/access.h +++ b/include/access.h @@ -123,8 +123,8 @@ class CoreExport ChanAccess : public Serializable virtual void AccessUnserialize(const Anope::string &data) = 0; /* Comparison operators to other Access entries */ - bool operator>(const ChanAccess &other) const; - bool operator<(const ChanAccess &other) const; + virtual bool operator>(const ChanAccess &other) const; + virtual bool operator<(const ChanAccess &other) const; bool operator>=(const ChanAccess &other) const; bool operator<=(const ChanAccess &other) const; }; diff --git a/include/anope.h b/include/anope.h index 51ece1cd6..07ed29ebf 100644 --- a/include/anope.h +++ b/include/anope.h @@ -762,17 +762,31 @@ template<typename T> inline T convertTo(const Anope::string &s, bool failIfLefto */ #ifdef DEBUG_BUILD # include <typeinfo> -#endif -template<typename T, typename O> inline T anope_dynamic_static_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("anope_dynamic_static_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; +} + +template<typename T, typename O> inline T anope_dynamic_static_cast(O& ref) +{ + try + { + return dynamic_cast<T>(ref); + } + catch (const std::bad_cast &ex) + { + throw CoreException(Anope::string("std::bad_cast from anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O&).name() + "): " + ex.what()); + } +} #else +template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr) +{ return static_cast<T>(ptr); -#endif } +#endif #endif // ANOPE_H |
