compare.h 463 B

12345678910111213141516171819
  1. #pragma once
  2. #include <compare> // IWYU pragma: keep
  3. #include <version>
  4. // Apple Clang does not properly support <=> in the STL - so we need to force it
  5. #if __cpp_lib_three_way_comparison < 201907L
  6. namespace std {
  7. template <typename T> auto operator<=>(T const & lhs, T const & rhs) {
  8. if (lhs < rhs) {
  9. return std::strong_ordering::less;
  10. }
  11. if (lhs > rhs) {
  12. return std::strong_ordering::greater;
  13. }
  14. return std::strong_ordering::equal;
  15. }
  16. }
  17. #endif