MythTV  master
ternarycompare.h
Go to the documentation of this file.
1 #ifndef TERNARY_COMPARE_H_
2 #define TERNARY_COMPARE_H_
3 
4 #include <type_traits>
5 
6 #include <QChar>
7 
21 template<typename T>
22 std::enable_if_t<std::is_integral_v<T>, int>
23 inline ternary_compare(const T a, const T b)
24 {
25  if (a < b) return -1;
26  if (a > b) return +1;
27  return 0; // a == b
28 }
29 // QChar should be uint16_t
30 inline int ternary_compare(const QChar a, const QChar b)
31 {
32  if (a < b) return -1;
33  if (a > b) return +1;
34  return 0; // a == b
35 }
36 
37 #endif // TERNARY_COMPARE_H_
ternary_compare
std::enable_if_t< std::is_integral_v< T >, int > ternary_compare(const T a, const T b)
balanced ternary (three way) comparison
Definition: ternarycompare.h:23