Skip to content

Commit 5029273

Browse files
committed
Use std::unique_ptr instead of std::auto_ptr
1 parent 63e3079 commit 5029273

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed

.travis.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,44 @@ addons:
4242
- python3-dev
4343
- libboost-all-dev
4444
- xsltproc
45+
- docbook-xsl
4546
- python-docutils
4647

48+
49+
cache:
50+
directories:
51+
- $HOME/Boost
52+
4753
before_install:
48-
# The Trusty image has several Python versions pre-installed compiled with
49-
# conflicting UCS2 and UCS4 unicode. Modify the PATH to skip the TravisCI python.
50-
# See https://github.com/travis-ci/travis-ci/issues/4948 for details.
51-
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
52-
- sudo pip install future
54+
# The Trusty image has several Python versions pre-installed compiled with
55+
# conflicting UCS2 and UCS4 unicode. Modify the PATH to skip the TravisCI python.
56+
# See https://github.com/travis-ci/travis-ci/issues/4948 for details.
57+
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
58+
- sudo pip install future
5359

5460
install:
61+
# Install our own version of Boost (the subset we need) as the system version is
62+
# too old (for C++11 support).
63+
- rm -rf $HOME/Boost
64+
- |
65+
set -e
66+
if [ ! -d $HOME/Boost ]; then
67+
echo "rebuilding Boost prerequisites"
68+
wget https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download
69+
tar xf download
70+
pushd boost_1_61_0
71+
./bootstrap.sh
72+
./b2 tools/bcp
73+
mkdir -p $HOME/Boost
74+
dist/bin/bcp python tools/boostbook tools/quickbook $HOME/Boost &> /dev/null
75+
popd
76+
fi
5577
5678
before_script:
5779
- scons --version
5880

5981
script:
60-
- scons config --python=$PYTHON
82+
- scons config --python=$PYTHON --boost-include=$HOME/Boost
6183
- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
6284

6385
after_success:

include/boost/python/make_constructor.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ namespace detail
4545
template <class U>
4646
void dispatch(U* x, mpl::true_) const
4747
{
48-
std::auto_ptr<U> owner(x);
49-
dispatch(owner, mpl::false_());
48+
#if __cplusplus < 201103L
49+
std::auto_ptr<U> owner(x);
50+
dispatch(owner, mpl::false_());
51+
#else
52+
std::unique_ptr<U> owner(x);
53+
dispatch(std::move(owner), mpl::false_());
54+
#endif
5055
}
5156

5257
template <class Ptr>
@@ -58,7 +63,11 @@ namespace detail
5863

5964
void* memory = holder::allocate(this->m_self, offsetof(instance_t, storage), sizeof(holder));
6065
try {
66+
#if __cplusplus < 201103L
6167
(new (memory) holder(x))->install(this->m_self);
68+
#else
69+
(new (memory) holder(std::move(x)))->install(this->m_self);
70+
#endif
6271
}
6372
catch(...) {
6473
holder::deallocate(this->m_self, memory);

include/boost/python/object/make_ptr_instance.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ struct make_ptr_instance
2121
template <class Arg>
2222
static inline Holder* construct(void* storage, PyObject*, Arg& x)
2323
{
24-
return new (storage) Holder(x);
24+
#if __cplusplus < 201103L
25+
return new (storage) Holder(x);
26+
#else
27+
return new (storage) Holder(std::move(x));
28+
#endif
2529
}
2630

2731
template <class Ptr>

include/boost/python/object/pointer_holder.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,21 @@ struct pointer_holder_back_reference : instance_holder
107107

108108
template <class Pointer, class Value>
109109
inline pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
110+
#if __cplusplus < 201103L
110111
: m_p(p)
112+
#else
113+
: m_p(std::move(p))
114+
#endif
111115
{
112116
}
113117

114118
template <class Pointer, class Value>
115119
inline pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_reference(Pointer p)
120+
#if __cplusplus < 201103L
116121
: m_p(p)
122+
#else
123+
: m_p(std::move(p))
124+
#endif
117125
{
118126
}
119127

include/boost/python/object/py_function.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ struct py_function
135135
{}
136136

137137
py_function(py_function const& rhs)
138-
: m_impl(rhs.m_impl)
138+
#if __cplusplus < 201103L
139+
: m_impl(rhs.m_impl)
140+
#else
141+
: m_impl(std::move(rhs.m_impl))
142+
#endif
139143
{}
140144

141145
PyObject* operator()(PyObject* args, PyObject* kw) const
@@ -164,7 +168,11 @@ struct py_function
164168
}
165169

166170
private:
171+
#if __cplusplus < 201103L
167172
mutable std::auto_ptr<py_function_impl_base> m_impl;
173+
#else
174+
mutable std::unique_ptr<py_function_impl_base> m_impl;
175+
#endif
168176
};
169177

170178
}}} // namespace boost::python::objects

include/boost/python/to_python_indirect.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ namespace detail
8686
// copy constructor.
8787
# if defined(__ICL) && __ICL < 600
8888
typedef boost::shared_ptr<T> smart_pointer;
89-
# else
89+
# elif __cplusplus < 201103L
9090
typedef std::auto_ptr<T> smart_pointer;
91+
# else
92+
typedef std::unique_ptr<T> smart_pointer;
9193
# endif
9294
typedef objects::pointer_holder<smart_pointer, T> holder_t;
9395

test/SConscript

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ for test in [('injected',),
4444
('polymorphism',),
4545
('polymorphism2',),
4646
('wrapper_held_type',),
47-
('polymorphism2_auto_ptr',),
48-
('auto_ptr',),
4947
('minimal',),
5048
('args',),
5149
('raw_ctor',),
@@ -94,6 +92,18 @@ for test in [('injected',),
9492
('pointer_vector',)]:
9593
tests+=env.BPLTest(*test)
9694

95+
if env['CXX11']:
96+
for test in [
97+
]:
98+
tests+=env.BPLTest(*test)
99+
else:
100+
for test in [
101+
('polymorphism2_auto_ptr',),
102+
('auto_ptr',),
103+
]:
104+
tests+=env.BPLTest(*test)
105+
106+
97107
test = env.BoostRunPythonScript('test_builtin_converters.py')
98108
Depends(
99109
test,

0 commit comments

Comments
 (0)