2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00

Use std::unique_ptr instead of std::auto_ptr

This commit is contained in:
Stefan Seefeld
2016-09-01 20:56:06 -04:00
parent 63e3079a16
commit 5029273ca8
7 changed files with 76 additions and 13 deletions

View File

@@ -45,8 +45,13 @@ namespace detail
template <class U>
void dispatch(U* x, mpl::true_) const
{
std::auto_ptr<U> owner(x);
dispatch(owner, mpl::false_());
#if __cplusplus < 201103L
std::auto_ptr<U> owner(x);
dispatch(owner, mpl::false_());
#else
std::unique_ptr<U> owner(x);
dispatch(std::move(owner), mpl::false_());
#endif
}
template <class Ptr>
@@ -58,7 +63,11 @@ namespace detail
void* memory = holder::allocate(this->m_self, offsetof(instance_t, storage), sizeof(holder));
try {
#if __cplusplus < 201103L
(new (memory) holder(x))->install(this->m_self);
#else
(new (memory) holder(std::move(x)))->install(this->m_self);
#endif
}
catch(...) {
holder::deallocate(this->m_self, memory);

View File

@@ -21,7 +21,11 @@ struct make_ptr_instance
template <class Arg>
static inline Holder* construct(void* storage, PyObject*, Arg& x)
{
return new (storage) Holder(x);
#if __cplusplus < 201103L
return new (storage) Holder(x);
#else
return new (storage) Holder(std::move(x));
#endif
}
template <class Ptr>

View File

@@ -107,13 +107,21 @@ struct pointer_holder_back_reference : instance_holder
template <class Pointer, class Value>
inline pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
#if __cplusplus < 201103L
: m_p(p)
#else
: m_p(std::move(p))
#endif
{
}
template <class Pointer, class Value>
inline pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_reference(Pointer p)
#if __cplusplus < 201103L
: m_p(p)
#else
: m_p(std::move(p))
#endif
{
}

View File

@@ -135,7 +135,11 @@ struct py_function
{}
py_function(py_function const& rhs)
: m_impl(rhs.m_impl)
#if __cplusplus < 201103L
: m_impl(rhs.m_impl)
#else
: m_impl(std::move(rhs.m_impl))
#endif
{}
PyObject* operator()(PyObject* args, PyObject* kw) const
@@ -164,7 +168,11 @@ struct py_function
}
private:
#if __cplusplus < 201103L
mutable std::auto_ptr<py_function_impl_base> m_impl;
#else
mutable std::unique_ptr<py_function_impl_base> m_impl;
#endif
};
}}} // namespace boost::python::objects

View File

@@ -86,8 +86,10 @@ namespace detail
// copy constructor.
# if defined(__ICL) && __ICL < 600
typedef boost::shared_ptr<T> smart_pointer;
# else
# elif __cplusplus < 201103L
typedef std::auto_ptr<T> smart_pointer;
# else
typedef std::unique_ptr<T> smart_pointer;
# endif
typedef objects::pointer_holder<smart_pointer, T> holder_t;