casts inlining and some code tidy-up

This commit is contained in:
Aleksandar Fabijanic 2008-05-13 23:26:35 +00:00
parent bad44e6e46
commit 96c57718c4

View File

@ -169,7 +169,7 @@ private:
template <typename ValueType> template <typename ValueType>
ValueType* AnyCast(Any* operand) inline ValueType* AnyCast(Any* operand)
/// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer /// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer
/// to the stored value. /// to the stored value.
/// ///
@ -184,7 +184,7 @@ ValueType* AnyCast(Any* operand)
template <typename ValueType> template <typename ValueType>
const ValueType* AnyCast(const Any* operand) inline const ValueType* AnyCast(const Any* operand)
/// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer /// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer
/// to the stored value. /// to the stored value.
/// ///
@ -225,7 +225,8 @@ ValueType AnyCast(Any& operand)
/// these cases. /// these cases.
{ {
ValueType* result = AnyCast<ValueType>(&operand); ValueType* result = AnyCast<ValueType>(&operand);
if (!result) throw BadCastException("Failed to convert between Any types"); if (!result)
throw BadCastException("Failed to convert between Any types");
return *result; return *result;
} }
@ -238,7 +239,8 @@ const ValueType& RefAnyCast(const Any & operand)
/// const MyType& tmp = RefAnyCast<MyType>(anAny); /// const MyType& tmp = RefAnyCast<MyType>(anAny);
{ {
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand)); ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
if (!result) throw BadCastException("RefAnyCast: Failed to convert between const Any types"); if (!result)
throw BadCastException("RefAnyCast: Failed to convert between const Any types");
return *result; return *result;
} }
@ -251,13 +253,14 @@ ValueType& RefAnyCast(Any& operand)
/// MyType& tmp = RefAnyCast<MyType>(anAny); /// MyType& tmp = RefAnyCast<MyType>(anAny);
{ {
ValueType* result = AnyCast<ValueType>(&operand); ValueType* result = AnyCast<ValueType>(&operand);
if (!result) throw BadCastException("RefAnyCast: Failed to convert between Any types"); if (!result)
throw BadCastException("RefAnyCast: Failed to convert between Any types");
return *result; return *result;
} }
template <typename ValueType> template <typename ValueType>
ValueType* UnsafeAnyCast(Any* operand) inline ValueType* UnsafeAnyCast(Any* operand)
/// The "unsafe" versions of AnyCast are not part of the /// The "unsafe" versions of AnyCast are not part of the
/// public interface and may be removed at any time. They are /// public interface and may be removed at any time. They are
/// required where we know what type is stored in the any and can't /// required where we know what type is stored in the any and can't
@ -269,7 +272,7 @@ ValueType* UnsafeAnyCast(Any* operand)
template <typename ValueType> template <typename ValueType>
const ValueType* UnsafeAnyCast(const Any* operand) inline const ValueType* UnsafeAnyCast(const Any* operand)
/// The "unsafe" versions of AnyCast are not part of the /// The "unsafe" versions of AnyCast are not part of the
/// public interface and may be removed at any time. They are /// public interface and may be removed at any time. They are
/// required where we know what type is stored in the any and can't /// required where we know what type is stored in the any and can't