Prefer make_unique over make_shared
This commit is contained in:
parent
6ecbaab2fe
commit
5a947b5035
@ -77,9 +77,9 @@ namespace chaiscript
|
|||||||
|
|
||||||
struct Object_Data
|
struct Object_Data
|
||||||
{
|
{
|
||||||
static std::shared_ptr<Data> get(Boxed_Value::Void_Type, bool t_return_value)
|
static std::unique_ptr<Data> get(Boxed_Value::Void_Type, bool t_return_value)
|
||||||
{
|
{
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
detail::Get_Type_Info<void>::get(),
|
detail::Get_Type_Info<void>::get(),
|
||||||
chaiscript::detail::Any(),
|
chaiscript::detail::Any(),
|
||||||
false,
|
false,
|
||||||
@ -89,15 +89,15 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(const std::shared_ptr<T> *obj, bool t_return_value)
|
static std::unique_ptr<Data> get(const std::shared_ptr<T> *obj, bool t_return_value)
|
||||||
{
|
{
|
||||||
return get(*obj, t_return_value);
|
return get(*obj, t_return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(const std::shared_ptr<T> &obj, bool t_return_value)
|
static std::unique_ptr<Data> get(const std::shared_ptr<T> &obj, bool t_return_value)
|
||||||
{
|
{
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
detail::Get_Type_Info<T>::get(),
|
detail::Get_Type_Info<T>::get(),
|
||||||
chaiscript::detail::Any(obj),
|
chaiscript::detail::Any(obj),
|
||||||
false,
|
false,
|
||||||
@ -107,10 +107,10 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(std::shared_ptr<T> &&obj, bool t_return_value)
|
static std::unique_ptr<Data> get(std::shared_ptr<T> &&obj, bool t_return_value)
|
||||||
{
|
{
|
||||||
auto ptr = obj.get();
|
auto ptr = obj.get();
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
detail::Get_Type_Info<T>::get(),
|
detail::Get_Type_Info<T>::get(),
|
||||||
chaiscript::detail::Any(std::move(obj)),
|
chaiscript::detail::Any(std::move(obj)),
|
||||||
false,
|
false,
|
||||||
@ -120,23 +120,23 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(T *t, bool t_return_value)
|
static std::unique_ptr<Data> get(T *t, bool t_return_value)
|
||||||
{
|
{
|
||||||
return get(std::ref(*t), t_return_value);
|
return get(std::ref(*t), t_return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(const T *t, bool t_return_value)
|
static std::unique_ptr<Data> get(const T *t, bool t_return_value)
|
||||||
{
|
{
|
||||||
return get(std::cref(*t), t_return_value);
|
return get(std::cref(*t), t_return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(std::reference_wrapper<T> obj, bool t_return_value)
|
static std::unique_ptr<Data> get(std::reference_wrapper<T> obj, bool t_return_value)
|
||||||
{
|
{
|
||||||
auto p = &obj.get();
|
auto p = &obj.get();
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
detail::Get_Type_Info<T>::get(),
|
detail::Get_Type_Info<T>::get(),
|
||||||
chaiscript::detail::Any(std::move(obj)),
|
chaiscript::detail::Any(std::move(obj)),
|
||||||
true,
|
true,
|
||||||
@ -146,11 +146,11 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::shared_ptr<Data> get(T t, bool t_return_value)
|
static std::unique_ptr<Data> get(T t, bool t_return_value)
|
||||||
{
|
{
|
||||||
auto p = std::make_shared<T>(std::move(t));
|
auto p = std::make_shared<T>(std::move(t));
|
||||||
auto ptr = p.get();
|
auto ptr = p.get();
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
detail::Get_Type_Info<T>::get(),
|
detail::Get_Type_Info<T>::get(),
|
||||||
chaiscript::detail::Any(std::move(p)),
|
chaiscript::detail::Any(std::move(p)),
|
||||||
false,
|
false,
|
||||||
@ -159,9 +159,9 @@ namespace chaiscript
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<Data> get()
|
static std::unique_ptr<Data> get()
|
||||||
{
|
{
|
||||||
return std::make_shared<Data>(
|
return std::make_unique<Data>(
|
||||||
Type_Info(),
|
Type_Info(),
|
||||||
chaiscript::detail::Any(),
|
chaiscript::detail::Any(),
|
||||||
false,
|
false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user