[libcxx-commits] [PATCH] D111514: [libc++] [P1614] Implement the second half of [cmp.alg]: compare_{strong, weak, partial}_fallback.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 11 10:31:37 PDT 2021


Quuxplusone marked 3 inline comments as done.
Quuxplusone added inline comments.


================
Comment at: libcxx/include/__compare/compare_partial_order_fallback.h:55
+                               _VSTD::forward<_Ep>(__e) < _VSTD::forward<_Fp>(__f) ? partial_ordering::less :
+                               _VSTD::forward<_Fp>(__f) < _VSTD::forward<_Ep>(__e) ? partial_ordering::greater :
+                               partial_ordering::unordered;
----------------
Mordante wrote:
> The same argument can be forwarded multiple times. Can that give an issue with some evil rvalue comparison operators?
Physically, yes. Semantically, no, either because that would be UB (violating some semantic requirement or other), or because that would be completely expected and documented behavior — notice that http://eel.is/c++draft/cmp.alg#4 says `compare_strong_order_fallback(E, F)` is //expression-equivalent to// exactly this expression, "except that E and F are evaluated only once" (which is Standardese for "they're function arguments, not macro arguments," so e.g. `std::compare_strong_order_fallback(++i, j)` does one increment of `i`, not up-to-three increments, no matter how the comparison turns out).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111514/new/

https://reviews.llvm.org/D111514



More information about the libcxx-commits mailing list