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 249df7cbdb. The manipulation in test_factory_constructors.py is NOT reverted in this commit.

[skip ci]
This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-02-11 18:28:39 -08:00
parent 67c2910308
commit 23036a45eb
4 changed files with 9 additions and 13 deletions

View File

@ -1385,19 +1385,15 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
using cast_op_type = conditional_t<
std::is_same<remove_reference_t<T_>, T const *>::value,
T const *,
conditional_t<
std::is_same<remove_reference_t<T_>, T *>::value,
conditional_t<std::is_same<remove_reference_t<T_>, T *>::value,
T *,
conditional_t<std::is_same<T_, T const &>::value,
T const &,
conditional_t<std::is_same<T_, T &>::value,
T &,
conditional_t<std::is_same<T_, T &&>::value, T &&, T>>>>>;
conditional_t<std::is_same<T_, T &>::value, T &, T>>>>;
// clang-format off
operator T() { return this->loaded_as_lvalue_ref(); }
operator T&&() && { return this->loaded_as_rvalue_ref(); }
operator T const&() { return this->loaded_as_lvalue_ref(); }
operator T&() { return this->loaded_as_lvalue_ref(); }
operator T const*() { return this->loaded_as_raw_ptr_unowned(); }

View File

@ -23,8 +23,8 @@ def test_cast():
def test_load():
assert m.pass_valu_atyp(m.atyp("Valu")) == "pass_valu:Valu.MvCtor.MvCtor"
assert m.pass_rref_atyp(m.atyp("Rref")) == "pass_rref:Rref.MvCtor"
assert m.pass_valu_atyp(m.atyp("Valu")) == "pass_valu:Valu.MvCtor.CpCtor"
assert m.pass_rref_atyp(m.atyp("Rref")) == "pass_rref:Rref.MvCtor.CpCtor"
assert m.pass_cref_atyp(m.atyp("Cref")) == "pass_cref:Cref.MvCtor"
assert m.pass_mref_atyp(m.atyp("Mref")) == "pass_mref:Mref.MvCtor"
assert m.pass_cptr_atyp(m.atyp("Cptr")) == "pass_cptr:Cptr.MvCtor"

View File

@ -62,7 +62,7 @@ def test_methods_and_attributes():
assert cstats.alive() == 0
assert cstats.values() == ["32"]
assert cstats.default_constructions == 1
assert cstats.copy_constructions in (2, 1) # SMART_HOLDER_WIP
assert cstats.copy_constructions == 2
assert cstats.move_constructions >= 2
assert cstats.copy_assignments == 0
assert cstats.move_assignments == 0

View File

@ -230,7 +230,7 @@ def test_move_support():
assert nc_stats.values() == ["4", "9", "9", "9"]
assert mv_stats.values() == ["4", "5", "7", "7"]
assert nc_stats.copy_constructions == 0
assert mv_stats.copy_constructions in (1, 0) # SMART_HOLDER_WIP
assert mv_stats.copy_constructions == 1
assert nc_stats.move_constructions >= 0
assert mv_stats.move_constructions >= 0