Copy-and-swap with inheritance