compare.h 828 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <util/generic/string.h>
  3. #include <string_view>
  4. namespace NYT {
  5. ////////////////////////////////////////////////////////////////////////////////
  6. //! Compares #lhs with #rhs;
  7. //! returns -1 (if |lhs < rhs|), 0 (if |lhs == rhs|), or 1 (|lhs > rhs|).
  8. template <class T>
  9. int TernaryCompare(const T& lhs, const T& rhs);
  10. //! Same as #TernaryCompare but handles NaN values gracefully
  11. //! (assuming NaNs are larger than any regular number and all NaNs are equal).
  12. //! If |T| is not a floating-point type, #NaNSafeTernaryCompare is equivalent to #TernaryCompare.
  13. template <class T>
  14. int NaNSafeTernaryCompare(const T& lhs, const T& rhs);
  15. ////////////////////////////////////////////////////////////////////////////////
  16. } // namespace NYT
  17. #define COMPARE_INL_H_
  18. #include "compare-inl.h"
  19. #undef COMPARE_INL_H_