Closed redboltz closed 2 years ago
Hi Takatoshi,
Your assumptions are all correct. To summarize, an iterator to a given element will point always to that element regardless of whether the element or other elements are modified or whether other elements are inserted or erased. Naturally, the position of the iterator/element in the index will vary as these operations take place, but not their pointing consistently to the same element.
All clear? Best,
Thank you for the prompt answer!
According to the document: https://www.boost.org/doc/libs/1_77_0/libs/multi_index/doc/reference/seq_indices.html
I wrote the following PoC code. Before modify() calling, it2 is point to the value order=2. After modify() is called, the order is updated to 10. it2 is now point to updated element. (order 10)
The it2 is now point to the last element because the order is the biggest value(10). So
assert(it2 == it10)
should success.it3 is also modified by modify() call. it3 is got before it2 's modification. it3 isn't effected by it2 modification.
Am I understanding correctly?
The actual usecase is calling multiple async APIs (Boost.Asio) on the single thread. And async completion handler captures the iterator that points to multi index element. The multi_index container could be reordered by modify but never added and removed in my usecase.
https://wandbox.org/permlink/k0CWgffmiexV4mVt