diff --git a/.travis.yml b/.travis.yml index b336967c..8e345c16 100644 --- a/.travis.yml +++ b/.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: diff --git a/include/boost/python/make_constructor.hpp b/include/boost/python/make_constructor.hpp index 093703bb..92a7951d 100644 --- a/include/boost/python/make_constructor.hpp +++ b/include/boost/python/make_constructor.hpp @@ -45,8 +45,13 @@ namespace detail template void dispatch(U* x, mpl::true_) const { - std::auto_ptr owner(x); - dispatch(owner, mpl::false_()); +#if __cplusplus < 201103L + std::auto_ptr owner(x); + dispatch(owner, mpl::false_()); +#else + std::unique_ptr owner(x); + dispatch(std::move(owner), mpl::false_()); +#endif } template @@ -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); diff --git a/include/boost/python/object/make_ptr_instance.hpp b/include/boost/python/object/make_ptr_instance.hpp index 9fdb23f6..3a281902 100644 --- a/include/boost/python/object/make_ptr_instance.hpp +++ b/include/boost/python/object/make_ptr_instance.hpp @@ -21,7 +21,11 @@ struct make_ptr_instance template 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 diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index 27d95193..b28cbd83 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -107,13 +107,21 @@ struct pointer_holder_back_reference : instance_holder template inline pointer_holder::pointer_holder(Pointer p) +#if __cplusplus < 201103L : m_p(p) +#else + : m_p(std::move(p)) +#endif { } template inline pointer_holder_back_reference::pointer_holder_back_reference(Pointer p) +#if __cplusplus < 201103L : m_p(p) +#else + : m_p(std::move(p)) +#endif { } diff --git a/include/boost/python/object/py_function.hpp b/include/boost/python/object/py_function.hpp index ba9aadf4..05cedfa0 100644 --- a/include/boost/python/object/py_function.hpp +++ b/include/boost/python/object/py_function.hpp @@ -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 m_impl; +#else + mutable std::unique_ptr m_impl; +#endif }; }}} // namespace boost::python::objects diff --git a/include/boost/python/to_python_indirect.hpp b/include/boost/python/to_python_indirect.hpp index 23ad0263..af6ed33b 100644 --- a/include/boost/python/to_python_indirect.hpp +++ b/include/boost/python/to_python_indirect.hpp @@ -86,8 +86,10 @@ namespace detail // copy constructor. # if defined(__ICL) && __ICL < 600 typedef boost::shared_ptr smart_pointer; -# else +# elif __cplusplus < 201103L typedef std::auto_ptr smart_pointer; +# else + typedef std::unique_ptr smart_pointer; # endif typedef objects::pointer_holder holder_t; diff --git a/test/SConscript b/test/SConscript index 896783c8..c62b8bc4 100644 --- a/test/SConscript +++ b/test/SConscript @@ -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,