The program below as-is inserts a set of values into a multi_index_container with ordered_non_unique indices via a for loop, with each element being inserted individually. When the elements with the key "Bob" (as identified by equal_range) are iterated over, they appear in the same order as they were inserted (which can be seen by looking at the age of each "Bob"). However, if you change the #if 1 to #if 0 then the elements are inserted via a call to the iterator range-based overload of insert. In this case, the ages of the people named "Bob" are not displayed in the order of insertion (which I assume would be forward pass from the begin iterator to the end iterator).
The program below as-is inserts a set of values into a multi_index_container with ordered_non_unique indices via a for loop, with each element being inserted individually. When the elements with the key "Bob" (as identified by equal_range) are iterated over, they appear in the same order as they were inserted (which can be seen by looking at the age of each "Bob"). However, if you change the
#if 1
to#if 0
then the elements are inserted via a call to the iterator range-based overload of insert. In this case, the ages of the people named "Bob" are not displayed in the order of insertion (which I assume would be forward pass from thebegin
iterator to theend
iterator).The following demo program can also be found here: https://gcc.godbolt.org/z/EvG4rW1ba