Use make_shared #64

This commit is contained in:
Jason Turner
2012-07-13 12:25:50 -06:00
parent bf4f90a4ff
commit 0a436398dd

View File

@@ -13,6 +13,7 @@
#include <map> #include <map>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/any.hpp> #include <boost/any.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
@@ -77,12 +78,11 @@ namespace chaiscript
{ {
static boost::shared_ptr<Data> get(Boxed_Value::Void_Type) static boost::shared_ptr<Data> get(Boxed_Value::Void_Type)
{ {
return boost::shared_ptr<Data> (new Data( return boost::make_shared<Data>(
detail::Get_Type_Info<void>::get(), detail::Get_Type_Info<void>::get(),
boost::any(), boost::any(),
false, false,
0) static_cast<void *>(0));
);
} }
template<typename T> template<typename T>
@@ -94,12 +94,11 @@ namespace chaiscript
template<typename T> template<typename T>
static boost::shared_ptr<Data> get(const boost::shared_ptr<T> &obj) static boost::shared_ptr<Data> get(const boost::shared_ptr<T> &obj)
{ {
return boost::shared_ptr<Data>(new Data( return boost::make_shared<Data>(
detail::Get_Type_Info<T>::get(), detail::Get_Type_Info<T>::get(),
boost::any(obj), boost::any(obj),
false, false,
obj.get()) obj.get());
);
} }
template<typename T> template<typename T>
@@ -111,34 +110,31 @@ namespace chaiscript
template<typename T> template<typename T>
static boost::shared_ptr<Data> get(boost::reference_wrapper<T> obj) static boost::shared_ptr<Data> get(boost::reference_wrapper<T> obj)
{ {
return boost::shared_ptr<Data>(new Data( return boost::make_shared<Data>(
detail::Get_Type_Info<T>::get(), detail::Get_Type_Info<T>::get(),
boost::any(obj), boost::any(obj),
true, true,
obj.get_pointer()) obj.get_pointer());
);
} }
template<typename T> template<typename T>
static boost::shared_ptr<Data> get(const T& t) static boost::shared_ptr<Data> get(const T& t)
{ {
boost::shared_ptr<T> p(new T(t)); boost::shared_ptr<T> p(new T(t));
return boost::shared_ptr<Data>(new Data( return boost::make_shared<Data>(
detail::Get_Type_Info<T>::get(), detail::Get_Type_Info<T>::get(),
boost::any(p), boost::any(p),
false, false,
p.get()) p.get());
);
} }
static boost::shared_ptr<Data> get() static boost::shared_ptr<Data> get()
{ {
return boost::shared_ptr<Data> (new Data( return boost::make_shared<Data>(
Type_Info(), Type_Info(),
boost::any(), boost::any(),
false, false,
0) static_cast<void *>(0));
);
} }
}; };