Move elements from std::multiset

221 views Asked by At

Is there anyway to move an element out of a std::multiset?

Since C++11 std::multiset::iterator is defined as a const bidirectional_iterator. I understand the reasoning is for keeping the elements sorted, but there seems to be no way to remove and then modify move only objects.

1

There are 1 answers

0
Joseph Artsimovich On BEST ANSWER

I don't think you can do that with std::multiset, though it should be doable with Boost's multi_index_container. It has a modify() method that takes an iterator and an updater functor. In that functor you should be able to move the value away.

For details, see Boost multi_index documentation.