Search code examples
c++algorithmstlstrict-weak-ordering

Why does the standard library require a strict weak ordering?


Why does C++ standard library work with a comparison function that is strict weak ordering? Why can't it be partial ordering?


Solution

  • A partial order would not be sufficient to implement some algorithms, such as a sorting algorithm. Since a partially ordered set does not necessarily define a relationship between all elements of the set, how would you sort a list of two items that do not have an order relationship within the partial order?