[algs] Sprinkle hb_min/max with hb-forward salad
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 8 May 2019 06:08:49 +0000 (23:08 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 8 May 2019 06:08:49 +0000 (23:08 -0700)
Let's see if fixes MSVC fail.  Though, the error doesn't make sense to me.

  hb-blob.cc
c:\projects\harfbuzz\src\hb-algs.hh(166): error C2440: 'return': cannot convert from 'unsigned int' to 'unsigned int &&' [C:\projects\harfbuzz\build\harfbuzz.vcxproj]
  c:\projects\harfbuzz\src\hb-algs.hh(166): note: You cannot bind an lvalue to an rvalue reference
  c:\projects\harfbuzz\src\hb-algs.hh(174): note: see reference to function template instantiation 'T &&<unnamed-type-hb_min>::impl<T,unsigned int&>(T &&,T2) const' being compiled
          with
          [
              T=unsigned int,
              T2=unsigned int &
          ]

src/hb-algs.hh

index 7738245..9e8a4ae 100644 (file)
@@ -163,11 +163,12 @@ struct
 {
   private:
   template <typename T, typename T2> auto
-  impl (T&& a, T2&& b) const HB_AUTO_RETURN (a <= b ? a : b)
+  impl (T&& a, T2&& b) const HB_AUTO_RETURN
+  (hb_forward<T> (a) <= hb_forward<T2> (b) ? hb_forward<T> (a) : hb_forward<T2> (b))
 
   public:
   template <typename T> auto
-  operator () (T&& a) const HB_AUTO_RETURN (a)
+  operator () (T&& a) const HB_AUTO_RETURN (hb_forward<T> (a))
 
   template <typename T, typename... Ts> auto
   operator () (T&& a, Ts&& ...ds) const HB_AUTO_RETURN
@@ -178,11 +179,12 @@ struct
 {
   private:
   template <typename T, typename T2> auto
-  impl (T&& a, T2&& b) const HB_AUTO_RETURN (a >= b ? a : b)
+  impl (T&& a, T2&& b) const HB_AUTO_RETURN
+  (hb_forward<T> (a) >= hb_forward<T2> (b) ? hb_forward<T> (a) : hb_forward<T2> (b))
 
   public:
   template <typename T> auto
-  operator () (T&& a) const HB_AUTO_RETURN (a)
+  operator () (T&& a) const HB_AUTO_RETURN (hb_forward<T> (a))
 
   template <typename T, typename... Ts> auto
   operator () (T&& a, Ts&& ...ds) const HB_AUTO_RETURN