File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1630,6 +1630,22 @@ struct move_only_holder_caster : type_caster_base<type> {
1630
1630
using base::typeinfo;
1631
1631
using base::value;
1632
1632
1633
+ // We must explicitly define the default constructor(s) since we define a
1634
+ // destructor; otherwise, the compiler will incorrectly use the copy
1635
+ // constructor.
1636
+ move_only_holder_caster () = default ;
1637
+ move_only_holder_caster (move_only_holder_caster&&) = default ;
1638
+ move_only_holder_caster (const move_only_holder_caster&) = delete ;
1639
+ ~move_only_holder_caster () {
1640
+ if (holder) {
1641
+ // If the argument was loaded into C++, but not transferred out,
1642
+ // then this was most likely part of a failed overload in
1643
+ // `argument_loader`. Transfer ownership back to Python.
1644
+ move_only_holder_caster::cast (
1645
+ std::move (holder), return_value_policy{}, handle{});
1646
+ }
1647
+ }
1648
+
1633
1649
static_assert (std::is_base_of<type_caster_base<type>, type_caster<type>>::value,
1634
1650
" Holder classes are only supported for custom types" );
1635
1651
You can’t perform that action at this time.
0 commit comments