chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

Rename Ord to StrongOrd, and WeakOrd to Ord #311

Closed danakj closed 1 year ago

danakj commented 1 year ago

The common case of ordering is just that a total order exists. The equality comparison of operator== is completely separate and requiring Ord does not mean the function may even use operator==. This is satisfied by std::weak_ordering. Since it is the common case, and it is the safer choice (you can't do it wrong with an incorrect operator==) and it matches the requirements of Ord in Rust, we name this Ord here.

C++ has an additional ordering to Rust which is std::strong_ordering. This ordering guarantees that (if Eq is satisifed) the operator== will return true iff the ordering of two elements are the same. That is each different object value is unique in the total ordering. This requires that the developer write operator== correctly (if at all), and it is uncommon to require this over std::weak_ordering. So we name this StrongOrd and document it accordingly.

Closes #310