mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-10-03 18:12:58 -04:00
use unique_ptr instead of auto_ptr - note that this modifies boost, which isn't a big deal since it is part of the repo, but we should really decouple the open source libs sometime
This commit is contained in:
@@ -109,7 +109,7 @@ struct arg_rvalue_from_python
|
||||
typedef typename boost::add_reference<
|
||||
T
|
||||
// We can't add_const here, or it would be impossible to pass
|
||||
// auto_ptr<U> args from Python to C++
|
||||
// unique_ptr<U> args from Python to C++
|
||||
>::type result_type;
|
||||
|
||||
arg_rvalue_from_python(PyObject*);
|
||||
|
||||
+3
-3
@@ -27,15 +27,15 @@ struct as_to_python_function
|
||||
convert_function_must_take_value_or_const_reference(&ToPython::convert, 1L);
|
||||
|
||||
// Yes, the const_cast below opens a hole in const-correctness,
|
||||
// but it's needed to convert auto_ptr<U> to python.
|
||||
// but it's needed to convert unique_ptr<U> to python.
|
||||
//
|
||||
// How big a hole is it? It allows ToPython::convert() to be
|
||||
// a function which modifies its argument. The upshot is that
|
||||
// client converters applied to const objects may invoke
|
||||
// undefined behavior. The damage, however, is limited by the
|
||||
// use of the assertion function. Thus, the only way this can
|
||||
// modify its argument is if T is an auto_ptr-like type. There
|
||||
// is still a const-correctness hole w.r.t. auto_ptr<U> const,
|
||||
// modify its argument is if T is an unique_ptr-like type. There
|
||||
// is still a const-correctness hole w.r.t. unique_ptr<U> const,
|
||||
// but c'est la vie.
|
||||
return ToPython::convert(*const_cast<T*>(static_cast<T const*>(x)));
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#ifndef COPY_CTOR_MUTATES_RHS_DWA2003219_HPP
|
||||
# define COPY_CTOR_MUTATES_RHS_DWA2003219_HPP
|
||||
|
||||
#include <boost/python/detail/is_auto_ptr.hpp>
|
||||
#include <boost/python/detail/is_unique_ptr.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
template <class T>
|
||||
struct copy_ctor_mutates_rhs
|
||||
: is_auto_ptr<T>
|
||||
: is_unique_ptr<T>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace boost { namespace python { namespace detail {
|
||||
|
||||
# if !defined(BOOST_NO_AUTO_PTR)
|
||||
|
||||
BOOST_PYTHON_IS_XXX_DEF(auto_ptr, std::auto_ptr, 1)
|
||||
BOOST_PYTHON_IS_XXX_DEF(unique_ptr, std::unique_ptr, 1)
|
||||
|
||||
# else
|
||||
|
||||
template <class T>
|
||||
struct is_auto_ptr : mpl::false_
|
||||
struct is_unique_ptr : mpl::false_
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace detail
|
||||
template <class U>
|
||||
void dispatch(U* x, mpl::true_) const
|
||||
{
|
||||
std::auto_ptr<U> owner(x);
|
||||
std::unique_ptr<U> owner(x);
|
||||
dispatch(owner, mpl::false_());
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ struct py_function
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::auto_ptr<py_function_impl_base> m_impl;
|
||||
mutable std::unique_ptr<py_function_impl_base> m_impl;
|
||||
};
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
@@ -81,13 +81,13 @@ namespace detail
|
||||
template <class T>
|
||||
static PyObject* execute(T* p)
|
||||
{
|
||||
// can't use auto_ptr with Intel 5 and VC6 Dinkum library
|
||||
// for some reason. We get link errors against the auto_ptr
|
||||
// can't use unique_ptr with Intel 5 and VC6 Dinkum library
|
||||
// for some reason. We get link errors against the unique_ptr
|
||||
// copy constructor.
|
||||
# if defined(__ICL) && __ICL < 600
|
||||
typedef boost::shared_ptr<T> smart_pointer;
|
||||
# else
|
||||
typedef std::auto_ptr<T> smart_pointer;
|
||||
typedef std::unique_ptr<T> smart_pointer;
|
||||
# endif
|
||||
typedef objects::pointer_holder<smart_pointer, T> holder_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user