Skip to content

Commit 364befd

Browse files
Maintain the same move semantics as pre-change status. This reverts the prior test change.
1 parent a30b715 commit 364befd

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

include/pybind11/cast.h

+9-11
Original file line numberDiff line numberDiff line change
@@ -1639,18 +1639,16 @@ struct move_only_holder_caster : type_caster_base<type> {
16391639
}
16401640

16411641
// Disable these?
1642-
explicit operator type*() { return this->value; }
1643-
explicit operator type&() { return *(this->value); }
1642+
// explicit operator type*() { return this->value; }
1643+
// explicit operator type&() { return *(this->value); }
16441644

1645-
explicit operator holder_type*() { return &holder; }
1645+
// explicit operator holder_type*() { return &holder; }
16461646

1647-
// Workaround for Intel compiler bug
1648-
// see pybind11 issue 94
1649-
#if defined(__ICC) || defined(__INTEL_COMPILER)
1650-
operator holder_type&() { return holder; }
1651-
#else
1652-
explicit operator holder_type&() { return holder; }
1653-
#endif
1647+
// Force rvalue.
1648+
template <typename T>
1649+
using cast_op_type = holder_type&&;
1650+
1651+
explicit operator holder_type&&() { return std::move(holder); }
16541652

16551653
object extract_from_container(handle src) {
16561654
// See if this is a supported `move` container.
@@ -2152,7 +2150,7 @@ class argument_loader {
21522150

21532151
template <typename Return, typename Func, size_t... Is, typename Guard>
21542152
Return call_impl(Func &&f, index_sequence<Is...>, Guard &&) {
2155-
return std::forward<Func>(f)(std::forward<Args>(cast_op<Args>(std::move(std::get<Is>(argcasters))))...);
2153+
return std::forward<Func>(f)(cast_op<Args>(std::move(std::get<Is>(argcasters)))...);
21562154
}
21572155

21582156
std::tuple<make_caster<Args>...> argcasters;

tests/test_smart_ptr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_smart_ptr(capture):
9696
assert cstats.alive() == 0
9797
assert cstats.values() == ['from pointer'] * 10
9898
assert cstats.default_constructions == 30
99-
assert cstats.copy_constructions == 2
99+
assert cstats.copy_constructions == 12
100100
# assert cstats.move_constructions >= 0 # Doesn't invoke any
101101
assert cstats.copy_assignments == 30
102102
assert cstats.move_assignments == 0

0 commit comments

Comments
 (0)