It is safe now, when move semantics is used instead of a custom swap
function.
This is a partial backport of [[https://github.com/bitcoin/bitcoin/pull/26749 | core#26749]]
https://github.com/bitcoin/bitcoin/pull/26749/commits/95ad70ab652ddde7de65f633c36c1378b26a313a
Depends on D16146