Passing object ownership in C++
c++
Solution
`boost::interprocess` is a library for interprocess communication, so I wouldn't use it for different purposes.
As discussed on this forum:
http://objectmix.com/c/113487-std-auto_ptr-deprecated.html
`std::auto_ptr` will be declared deprecated in the next version of the standard, where it will be recommended the usage of `std::unique_ptr`, which requires rvalue references and move semantics to be implemented (that's a fairly complicated feature).
Until the new standard is released, I would simply try to disable the warning if possible, or ignore it, for maximum portability.
If you want to already switch to the next language standard, it is possible since rvalue references have been implemented (see http://russ.yanofsky.org/rref/), so also `std::unique_ptr` should be supported.
On of the advantages of the new semantics is that you can pass to the move constructor also a temporary or any rvalue; in other cases, this allows avoiding to copy (for instance) objects contained inside a `std::vector` (during reallocation) before destroying the original ones.
Problem
What is the best way to indicate that an object wants to take ownership of another object? So far, I've been using a `std::auto_ptr` in the public interface, so the client knows that the interface wants to take ownership of the passed object. However, the latest GCC tells me `auto_ptr` is deprecated, so I wonder what is recommended? `boost::interprocess::unique_pointer` looks like a good candidate, but is this really the best solution out there?