Removing operator T&&() && from smart_holder_type_caster, for compa… · pybind/pybind11@23036a4 (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1385,19 +1385,15 @@ struct smart_holder_type_caster : smart_holder_type_caster_load,
1385 1385 using cast_op_type = conditional_t<
1386 1386 std::is_same<remove_reference_t<T_>, T const *>::value,
1387 1387 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>>>>;
1396 1393
1397 1394 // clang-format off
1398 1395
1399 1396 operator T() { return this->loaded_as_lvalue_ref(); }
1400 -operator T&&() && { return this->loaded_as_rvalue_ref(); }
1401 1397 operator T const&() { return this->loaded_as_lvalue_ref(); }
1402 1398 operator T&() { return this->loaded_as_lvalue_ref(); }
1403 1399 operator T const*() { return this->loaded_as_raw_ptr_unowned(); }
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ def test_cast():
23 23
24 24
25 25 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"
28 28 assert m.pass_cref_atyp(m.atyp("Cref")) == "pass_cref:Cref.MvCtor"
29 29 assert m.pass_mref_atyp(m.atyp("Mref")) == "pass_mref:Mref.MvCtor"
30 30 assert m.pass_cptr_atyp(m.atyp("Cptr")) == "pass_cptr:Cptr.MvCtor"
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def test_methods_and_attributes():
62 62 assert cstats.alive() == 0
63 63 assert cstats.values() == ["32"]
64 64 assert cstats.default_constructions == 1
65 -assert cstats.copy_constructions in (2, 1) # SMART_HOLDER_WIP
65 +assert cstats.copy_constructions == 2
66 66 assert cstats.move_constructions >= 2
67 67 assert cstats.copy_assignments == 0
68 68 assert cstats.move_assignments == 0
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ def get_movable(self, a, b):
230 230 assert nc_stats.values() == ["4", "9", "9", "9"]
231 231 assert mv_stats.values() == ["4", "5", "7", "7"]
232 232 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
234 234 assert nc_stats.move_constructions >= 0
235 235 assert mv_stats.move_constructions >= 0
236 236