Fix double pointer cast test

This commit is contained in:
Jason Turner
2015-04-07 11:09:47 -06:00
parent 79181fe41e
commit 5114ca9d35

View File

@@ -81,16 +81,17 @@ namespace chaiscript
typedef Result * Result_Type; typedef Result * Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *) static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *)
{ {
if (!ob.get_type_info().is_const() && ob.get_type_info().bare_equal_type_info(typeid(Result))) if (ob.is_ref())
{ {
return static_cast<Result *>(throw_if_null(ob.get_ptr())); return &(ob.get().cast<std::reference_wrapper<Result> >()).get();
} else { } else {
throw chaiscript::detail::exception::bad_any_cast(); return (ob.get().cast<std::shared_ptr<Result> >()).get();
} }
} }
}; };
/// Cast_Helper_Inner for casting to a & type /// Cast_Helper_Inner for casting to a & type
template<typename Result> template<typename Result>
struct Cast_Helper_Inner<Result &> struct Cast_Helper_Inner<Result &>