Skip to content

Commit 23036a4

Browse files
committed
Removing operator T&&() && from smart_holder_type_caster, for compatibility with the behavior of type_caster_base. Enables reverting 2 of 3 test manipulations applied under commit 249df7c. The manipulation in test_factory_constructors.py is NOT reverted in this commit.
[skip ci]
1 parent 67c2910 commit 23036a4

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

include/pybind11/cast.h

+5-9
Original file line numberDiff line numberDiff line change
@@ -1385,19 +1385,15 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
13851385
using cast_op_type = conditional_t<
13861386
std::is_same<remove_reference_t<T_>, T const *>::value,
13871387
T const *,
1388-
conditional_t<
1389-
std::is_same<remove_reference_t<T_>, T *>::value,
1390-
T *,
1391-
conditional_t<std::is_same<T_, T const &>::value,
1392-
T const &,
1393-
conditional_t<std::is_same<T_, T &>::value,
1394-
T &,
1395-
conditional_t<std::is_same<T_, T &&>::value, T &&, T>>>>>;
1388+
conditional_t<std::is_same<remove_reference_t<T_>, T *>::value,
1389+
T *,
1390+
conditional_t<std::is_same<T_, T const &>::value,
1391+
T const &,
1392+
conditional_t<std::is_same<T_, T &>::value, T &, T>>>>;
13961393

13971394
// clang-format off
13981395

13991396
operator T() { return this->loaded_as_lvalue_ref(); }
1400-
operator T&&() && { return this->loaded_as_rvalue_ref(); }
14011397
operator T const&() { return this->loaded_as_lvalue_ref(); }
14021398
operator T&() { return this->loaded_as_lvalue_ref(); }
14031399
operator T const*() { return this->loaded_as_raw_ptr_unowned(); }

tests/test_class_sh_basic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def test_cast():
2323

2424

2525
def test_load():
26-
assert m.pass_valu_atyp(m.atyp("Valu")) == "pass_valu:Valu.MvCtor.MvCtor"
27-
assert m.pass_rref_atyp(m.atyp("Rref")) == "pass_rref:Rref.MvCtor"
26+
assert m.pass_valu_atyp(m.atyp("Valu")) == "pass_valu:Valu.MvCtor.CpCtor"
27+
assert m.pass_rref_atyp(m.atyp("Rref")) == "pass_rref:Rref.MvCtor.CpCtor"
2828
assert m.pass_cref_atyp(m.atyp("Cref")) == "pass_cref:Cref.MvCtor"
2929
assert m.pass_mref_atyp(m.atyp("Mref")) == "pass_mref:Mref.MvCtor"
3030
assert m.pass_cptr_atyp(m.atyp("Cptr")) == "pass_cptr:Cptr.MvCtor"

tests/test_methods_and_attributes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_methods_and_attributes():
6262
assert cstats.alive() == 0
6363
assert cstats.values() == ["32"]
6464
assert cstats.default_constructions == 1
65-
assert cstats.copy_constructions in (2, 1) # SMART_HOLDER_WIP
65+
assert cstats.copy_constructions == 2
6666
assert cstats.move_constructions >= 2
6767
assert cstats.copy_assignments == 0
6868
assert cstats.move_assignments == 0

tests/test_virtual_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def get_movable(self, a, b):
230230
assert nc_stats.values() == ["4", "9", "9", "9"]
231231
assert mv_stats.values() == ["4", "5", "7", "7"]
232232
assert nc_stats.copy_constructions == 0
233-
assert mv_stats.copy_constructions in (1, 0) # SMART_HOLDER_WIP
233+
assert mv_stats.copy_constructions == 1
234234
assert nc_stats.move_constructions >= 0
235235
assert mv_stats.move_constructions >= 0
236236

0 commit comments

Comments
 (0)