Is it possible to move an item out of a std::set?

前端 未结 2 712
忘了有多久
忘了有多久 2020-12-17 18:35

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.

2条回答
  •  无人及你
    2020-12-17 18:58

    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.

提交回复
热议问题