[libcxx-commits] [PATCH] D131395: [libc++] Implement `lexicographical_compare_three_way`

Adrian Vogelsgesang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 26 14:19:55 PDT 2022


avogelsgesang added inline comments.


================
Comment at: libcxx/test/support/test_comparisons.h:253
+  friend std::partial_ordering operator<=>(PartialComp, PartialComp) = default;
+};
+#endif
----------------
mumbleskates wrote:
> avogelsgesang wrote:
> > Mordante wrote:
> > > Why not complete the set with `std::strong_ordering`?
> > because for `strong_ordering` you can simply use a plain `int`. Or should I still add it for completeness?
> honestly you could probably just write `using StrongComp = int;`.
> 
> in the tests i've written so far i have used integral types for strong, floating points for partial, and only used structs for weak orderings.
> 
> to that end, it would be useful if PartialComp had an avenue to actually return `partial_ordering::unordered`. you could keep its member typed as an `int` and use `INT_MIN` as a sentinel for the unordered value, which could even allow us to test heterogenous orderable/unorderable values `constexpr` in gcc (which currently(?) does not allow comparing infinities and NaNs against different values in constant evaluation).
> 
> For additional completeness here we would add a `UserComp` struct whose `operator<=>` returns a `UserOrdering` typed value that implements the appropriate operators against literal zero; such types are useful for SFINAE testing and types that utilize `synth-three-way`.
> complete the set with `std::strong_ordering`

done

> `PartialComp` had an avenue to actually return `partial_ordering::unordered`

done

> `UserComp` struct whose `operator<=>` returns a `UserOrdering`

Added. But now gcc-11 crashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131395



More information about the libcxx-commits mailing list