Simplify a couple of random things

This commit is contained in:
Jason Turner
2015-06-23 11:48:01 -06:00
parent 83281bff52
commit a112d97141
2 changed files with 7 additions and 8 deletions

View File

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