mirror of
https://github.com/anope/anope.git
synced 2026-07-02 06:06:39 +02:00
Attempt #3
This commit is contained in:
+2
-15
@@ -762,26 +762,13 @@ template<typename T> inline T convertTo(const Anope::string &s, bool failIfLefto
|
||||
*/
|
||||
#ifdef DEBUG_BUILD
|
||||
# include <typeinfo>
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ class AccessChanAccess : public ChanAccess
|
||||
if (this->provider != other.provider)
|
||||
return ChanAccess::operator>(other);
|
||||
else
|
||||
return this->level > anope_dynamic_static_cast<const AccessChanAccess &, const ChanAccess &>(other).level;
|
||||
return this->level > anope_dynamic_static_cast<const AccessChanAccess *>(&other)->level;
|
||||
}
|
||||
|
||||
bool operator<(const ChanAccess &other) const anope_override
|
||||
@@ -57,7 +57,7 @@ class AccessChanAccess : public ChanAccess
|
||||
if (this->provider != other.provider)
|
||||
return ChanAccess::operator<(other);
|
||||
else
|
||||
return this->level < anope_dynamic_static_cast<const AccessChanAccess &, const ChanAccess &>(other).level;
|
||||
return this->level < anope_dynamic_static_cast<const AccessChanAccess *>(&other)->level;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user