I see two reasonable solutions to the problem of the member owning the parameter:
Foo::Foo(std::unique_ptr<int> parameter) : member(std::move(parameter)) { } Bar::Bar(std::unique_ptr<int> parameter) { member.swap(parameter); }
Which one is more idiomatic, easier to understand, easier to debug, easier to maintain, etc.?
Are there any additional solutions to the problem that I missed?
source share