Reduce versions of shared_ptr created

This commit is contained in:
Jason Turner 2015-03-23 13:44:40 -06:00
parent 9326539f3b
commit 04bceedf64
3 changed files with 4 additions and 4 deletions

View File

@ -158,7 +158,7 @@ namespace chaiscript
if (itr != m_instances.end()) { return itr->second; }
std::shared_ptr<T> new_instance(new T());
std::shared_ptr<T> new_instance(std::make_shared<T>());
m_instances.insert(std::make_pair(std::this_thread::get_id(), new_instance));

View File

@ -30,7 +30,7 @@ namespace chaiscript
Proxy_Function build_constructor_(Class (*)(Params...))
{
typedef std::shared_ptr<Class> (sig)(Params...);
return Proxy_Function(new Proxy_Function_Impl<sig>(std::function<sig>(&(constructor_<Class, Params...>))));
return Proxy_Function(static_cast<Proxy_Function_Impl_Base *>(new Proxy_Function_Impl<sig>(std::function<sig>(&(constructor_<Class, Params...>)))));
}
}
}

View File

@ -61,7 +61,7 @@ namespace chaiscript
{
/// \todo is it possible to reduce the number of templates generated here?
return Proxy_Function(
new Proxy_Function_Impl<typename FunctionSignature<decltype(to_function(t)) >::Signature>(to_function(t)));
static_cast<dispatch::Proxy_Function_Impl_Base *>(new Proxy_Function_Impl<typename FunctionSignature<decltype(to_function(t)) >::Signature>(to_function(t))));
}
};
@ -118,7 +118,7 @@ namespace chaiscript
template<typename T>
Proxy_Function fun(const std::function<T> &f)
{
return Proxy_Function(new dispatch::Proxy_Function_Impl<T>(f));
return Proxy_Function(static_cast<dispatch::Proxy_Function_Impl_Base *>(new dispatch::Proxy_Function_Impl<T>(f)));
}