Prevent moving of a unique_ptr C++11

c++, c++11, move-semantics, unique-ptr

Solution

Make it `const`

The `unique_ptr` move constructor takes a non-const rvalue reference, so can't be called with a `const` object.

const unique_ptr<int> owner(new int);
// ...
unique_ptr<int> thief = std::move(owner);  // ERROR

This allows `unique_ptr` to be used like a `boost::scoped_ptr`

Problem

Is there any way to prevent a user to explicity take ownership of a unique pointer with ``` std::move ``` ?

Original source