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

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 12 08:52:08 PDT 2021


Mordante accepted this revision as: Mordante.
Mordante added a comment.

LGTM but I'd like @ldionne to also have a look.



================
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;
----------------
Quuxplusone wrote:
> 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).
I read that part of the wording. I was mainly wondering about the fact that both `__e` and `__f` can be forwarded 3 times in the return statement. But when you're sure this is fine I'm happy.


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