Would do the same in C++ for values held by unique_ptr: take ownership of the pointer and then free it.
Am I missing something? Does it not work with std::move?
void drop(std::unique_ptr<T> x) {}
Or, you know, just call someX.reset(); or do someX = nullptr;. The drop call would be way noisier: drop(std::move(someX));
template <class T>
void drop(T&) = delete; // force callers to move
template <class T>
void drop(T&& x) {
T drop_me(std::move(x));
}
edit: fixed. template <class T>
void drop(T) {}
(Moving into a local in `drop(T&&)` also works.)