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 @@ -1551,6 +1551,22 @@ struct move_only_holder_caster : type_caster_base<type> {
1551
1551
using base::typeinfo;
1552
1552
using base::value;
1553
1553
1554
+ // We must explicitly define the default constructor(s) since we define a
1555
+ // destructor; otherwise, the compiler will incorrectly use the copy
1556
+ // constructor.
1557
+ move_only_holder_caster () = default ;
1558
+ move_only_holder_caster (move_only_holder_caster&&) = default ;
1559
+ move_only_holder_caster (const move_only_holder_caster&) = delete ;
1560
+ ~move_only_holder_caster () {
1561
+ if (holder) {
1562
+ // If the argument was loaded into C++, but not transferred out,
1563
+ // then this was most likely part of a failed overload in
1564
+ // `argument_loader`. Transfer ownership back to Python.
1565
+ move_only_holder_caster::cast (
1566
+ std::move (holder), return_value_policy{}, handle{});
1567
+ }
1568
+ }
1569
+
1554
1570
bool load (handle src, bool convert) {
1555
1571
return base::template load_impl<move_only_holder_caster<type, holder_type>>(src, convert);
1556
1572
}
You can’t perform that action at this time.
0 commit comments