According to the documentation, hashed index iterators remains valid when new elements are inserted into a multi_index. However when I attempted the following approach
auto& myIndex = myMultiIndex.get<0>();
auto range = myIndex.equal_range(x);
for (auto iter = range.first; iter != range.second; ++iter) {
myMultiIndex.emplace(someArgsRelatedToIter);
}
the range.first/range.second seem to become invalid: even though std::distance(range.first, range.second) == 1, the for loop actually gets executed twice. Am I somehow not using it correctly? Thanks!