File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1551,6 +1551,22 @@ struct move_only_holder_caster : type_caster_base<type> {
15511551 using base::typeinfo;
15521552 using base::value;
15531553
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+
15541570 bool load (handle src, bool convert) {
15551571 return base::template load_impl<move_only_holder_caster<type, holder_type>>(src, convert);
15561572 }
You can’t perform that action at this time.
0 commit comments