fixed a bug in RefAnyCast causing a crash if the cast is invalid

This commit is contained in:
Günter Obiltschnig
2020-02-13 21:56:59 +01:00
parent 0b59315443
commit 23da8c21c9

View File

@@ -561,6 +561,8 @@ const ValueType& RefAnyCast(const Any & operand)
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
{
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
{
@@ -570,6 +572,8 @@ const ValueType& RefAnyCast(const Any & operand)
s.append(typeid(ValueType).name());
s.append(1, ')');
}
throw BadCastException(s);
}
return *result;
}