mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
Use std::unique_ptr instead of std::auto_ptr
This commit is contained in:
34
.travis.yml
34
.travis.yml
@@ -42,22 +42,44 @@ addons:
|
||||
- python3-dev
|
||||
- libboost-all-dev
|
||||
- xsltproc
|
||||
- docbook-xsl
|
||||
- python-docutils
|
||||
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/Boost
|
||||
|
||||
before_install:
|
||||
# The Trusty image has several Python versions pre-installed compiled with
|
||||
# conflicting UCS2 and UCS4 unicode. Modify the PATH to skip the TravisCI python.
|
||||
# See https://github.com/travis-ci/travis-ci/issues/4948 for details.
|
||||
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
|
||||
- sudo pip install future
|
||||
# The Trusty image has several Python versions pre-installed compiled with
|
||||
# conflicting UCS2 and UCS4 unicode. Modify the PATH to skip the TravisCI python.
|
||||
# See https://github.com/travis-ci/travis-ci/issues/4948 for details.
|
||||
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
|
||||
- sudo pip install future
|
||||
|
||||
install:
|
||||
# Install our own version of Boost (the subset we need) as the system version is
|
||||
# too old (for C++11 support).
|
||||
- rm -rf $HOME/Boost
|
||||
- |
|
||||
set -e
|
||||
if [ ! -d $HOME/Boost ]; then
|
||||
echo "rebuilding Boost prerequisites"
|
||||
wget https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download
|
||||
tar xf download
|
||||
pushd boost_1_61_0
|
||||
./bootstrap.sh
|
||||
./b2 tools/bcp
|
||||
mkdir -p $HOME/Boost
|
||||
dist/bin/bcp python tools/boostbook tools/quickbook $HOME/Boost &> /dev/null
|
||||
popd
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- scons --version
|
||||
|
||||
script:
|
||||
- scons config --python=$PYTHON
|
||||
- scons config --python=$PYTHON --boost-include=$HOME/Boost
|
||||
- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
|
||||
|
||||
after_success:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ for test in [('injected',),
|
||||
('polymorphism',),
|
||||
('polymorphism2',),
|
||||
('wrapper_held_type',),
|
||||
('polymorphism2_auto_ptr',),
|
||||
('auto_ptr',),
|
||||
('minimal',),
|
||||
('args',),
|
||||
('raw_ctor',),
|
||||
@@ -94,6 +92,18 @@ for test in [('injected',),
|
||||
('pointer_vector',)]:
|
||||
tests+=env.BPLTest(*test)
|
||||
|
||||
if env['CXX11']:
|
||||
for test in [
|
||||
]:
|
||||
tests+=env.BPLTest(*test)
|
||||
else:
|
||||
for test in [
|
||||
('polymorphism2_auto_ptr',),
|
||||
('auto_ptr',),
|
||||
]:
|
||||
tests+=env.BPLTest(*test)
|
||||
|
||||
|
||||
test = env.BoostRunPythonScript('test_builtin_converters.py')
|
||||
Depends(
|
||||
test,
|
||||
|
||||
Reference in New Issue
Block a user