[libcxx-commits] [libcxx] [libc++] Optimize lexicographical_compare (PR #65279)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 1 08:49:14 PDT 2024
================
@@ -17,10 +17,19 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-// Tags to represent the canonical operations
+// Tags to represent the canonical operations.
+
+// syntactically, the operation is equivalent to calling `a == b`
struct __equal_tag {};
+
+// syntactically, the operation is equivalent to calling `a + b`
struct __plus_tag {};
-struct __less_tag {};
+
+// syntactically, the operation is equivalent to calling `a < b`, and these expressions
+// have to be true for any `a` and `b`:
+// - `(a < b) == (b > a)`
+// - `(!(a < b) && !(b < a)) == (a == b)`
----------------
ldionne wrote:
```suggestion
// - `(!(a < b) && !(b < a)) == (a == b)`
// Amongst other things, this is satisfied for std::less on integral types but also
// for ranges::less on all types due to an additional semantic requirement on
// that operation.
```
https://github.com/llvm/llvm-project/pull/65279
More information about the libcxx-commits
mailing list