File tree 4 files changed +10
-13
lines changed
4 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -1243,8 +1243,8 @@ struct arg_v : arg {
1243
1243
private:
1244
1244
template <typename T>
1245
1245
arg_v (arg &&base, T &&x, const char *descr = nullptr )
1246
- : arg(base), value(reinterpret_steal<object>(
1247
- detail::make_caster <T>::cast(x , return_value_policy::automatic, {}))),
1246
+ : arg(base), value(reinterpret_steal<object>(detail::make_caster<T>::cast(
1247
+ std::forward <T>(x) , return_value_policy::automatic, {}))),
1248
1248
descr (descr)
1249
1249
#if !defined(NDEBUG)
1250
1250
,
@@ -1491,7 +1491,7 @@ class unpacking_collector {
1491
1491
type_id<T>());
1492
1492
#endif
1493
1493
}
1494
- args_list.append (o );
1494
+ args_list.append (std::move (o) );
1495
1495
}
1496
1496
1497
1497
void process (list &args_list, detail::args_proxy ap) {
Original file line number Diff line number Diff line change @@ -640,9 +640,9 @@ class dtype : public object {
640
640
641
641
list names, formats, offsets;
642
642
for (auto &descr : field_descriptors) {
643
- names.append (descr.name );
644
- formats.append (descr.format );
645
- offsets.append (descr.offset );
643
+ names.append (std::move ( descr.name ) );
644
+ formats.append (std::move ( descr.format ) );
645
+ offsets.append (std::move ( descr.offset ) );
646
646
}
647
647
return dtype (std::move (names), std::move (formats), std::move (offsets), itemsize);
648
648
}
Original file line number Diff line number Diff line change @@ -268,10 +268,7 @@ class object : public handle {
268
268
// / Copy constructor; always increases the reference count
269
269
object (const object &o) : handle(o) { inc_ref (); }
270
270
// / Move constructor; steals the object from ``other`` and preserves its reference count
271
- object (object &&other) noexcept {
272
- m_ptr = other.m_ptr ;
273
- other.m_ptr = nullptr ;
274
- }
271
+ object (object &&other) noexcept : handle(other) { other.m_ptr = nullptr ; }
275
272
// / Destructor; automatically calls `handle::dec_ref()`
276
273
~object () { dec_ref (); }
277
274
@@ -1519,8 +1516,8 @@ class weakref : public object {
1519
1516
class slice : public object {
1520
1517
public:
1521
1518
PYBIND11_OBJECT_DEFAULT (slice, object, PySlice_Check)
1522
- slice (handle start, handle stop, handle step) {
1523
- m_ptr = PySlice_New (start.ptr (), stop.ptr (), step.ptr ());
1519
+ slice (handle start, handle stop, handle step)
1520
+ : object( PySlice_New(start.ptr(), stop.ptr(), step.ptr()), stolen_t {}) {
1524
1521
if (!m_ptr) {
1525
1522
pybind11_fail (" Could not allocate slice object!" );
1526
1523
}
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ struct set_caster {
79
79
for (auto &&value : src) {
80
80
auto value_ = reinterpret_steal<object>(
81
81
key_conv::cast (forward_like<T>(value), policy, parent));
82
- if (!value_ || !s.add (value_)) {
82
+ if (!value_ || !s.add (std::move ( value_) )) {
83
83
return handle ();
84
84
}
85
85
}
You can’t perform that action at this time.
0 commit comments