In C ++ 11, the std :: unordered_set container provides both insert overload and the new emplace function, so it can be used with non-copyable construct keys, for example std :: unique_ptr.
What happens if you want to delete one of these keys? Is it auto temp = std::move(*some_iterator)valid? Is there any function that allows us to erase an element and at the same time move it to the pace?
Edit: I tried to keep it short, sweet and simple, but to be more clear:
- Is there an iterator adapter (maybe move_iterator?) That will allow me to move an element from the container and remove that iterator?
- If not, why not? Should future C ++ include such an interface?
The situation seems impossible: you cannot cancel the key before deleting it, and after deleting it, you cannot gain access.
source
share