[algs] Add hb_min() and hb_max()
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 23:06:34 +0000 (16:06 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 23:06:34 +0000 (16:06 -0700)
src/hb-algs.hh

index adf5c48..2765e1c 100644 (file)
@@ -98,6 +98,17 @@ static const struct
   operator () (const Pair& pair) const { return pair.second; }
 } hb_second HB_UNUSED;
 
+static const struct
+{
+  template <typename T, typename T2> T
+  operator () (const T& a, const T2& b) const { return a <= b ? a : b; }
+} hb_min HB_UNUSED;
+static const struct
+{
+  template <typename T, typename T2> T
+  operator () (const T& a, const T2& b) const { return a >= b ? a : b; }
+} hb_max HB_UNUSED;
+
 
 /*
  * Bithacks.