If I have an object that only allows move-only semantics - is it possible to move items from a set? I can't seem to find a way to do this.
Note: This is an answer for C++ versions prior to C++17
No, it is not possible. There is no way to get non-const access to elements in a set
, and move requires non-const references. Allowing non-const access would make it trivially easy to break the invariants for set
.