9

Suppose I have two items, a and b, that compare the same. So a < b is false, and b < a is false. If these items are inserted into a std::multiset (or std::multimap) as keys, do I have any guarantees of their final sorted order?

I've checked a couple of references, but I couldn't find the answer. I'm tempted to think that there are no guarantees and that it's left up to each particular implementation.

Thanks.

Imbue
  • 3,897
  • 6
  • 40
  • 42
  • Possible duplicate of [Does std::multiset guarantee insertion order?](https://stackoverflow.com/questions/2643473/does-stdmultiset-guarantee-insertion-order) – underscore_d Aug 03 '17 at 14:40

1 Answers1

11

This thread implies that it is not guaranteed by the current standard but is met by all known current implementations, and gives a link to the C++0x draft standard that includes a guarantee.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622