diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 2420311ef..856972db7 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -153,7 +153,7 @@ struct hb_binder_t hb_reference_wrapper a; V v; }; -template +template auto hb_bind (Appl&& a, V&& v) HB_AUTO_RETURN (( hb_binder_t (a, v) )) @@ -790,64 +790,82 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o } +/* Operators. */ + struct hb_bitwise_and -{ +{ HB_PARTIALIZE(1); static constexpr bool passthru_left = false; static constexpr bool passthru_right = false; - template - auto operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & b) + template auto + operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & b) } HB_FUNCOBJ (hb_bitwise_and); struct hb_bitwise_or -{ +{ HB_PARTIALIZE(1); static constexpr bool passthru_left = true; static constexpr bool passthru_right = true; - template - auto operator () (const T &a, const T &b) const HB_AUTO_RETURN (a | b) + template auto + operator () (const T &a, const T &b) const HB_AUTO_RETURN (a | b) } HB_FUNCOBJ (hb_bitwise_or); struct hb_bitwise_xor -{ +{ HB_PARTIALIZE(1); static constexpr bool passthru_left = true; static constexpr bool passthru_right = true; - template - auto operator () (const T &a, const T &b) const HB_AUTO_RETURN (a ^ b) + template auto + operator () (const T &a, const T &b) const HB_AUTO_RETURN (a ^ b) } HB_FUNCOBJ (hb_bitwise_xor); struct hb_bitwise_sub -{ +{ HB_PARTIALIZE(1); static constexpr bool passthru_left = true; static constexpr bool passthru_right = false; - template - auto operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & ~b) + template auto + operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & ~b) } HB_FUNCOBJ (hb_bitwise_sub); struct -{ - HB_PARTIALIZE(0); - - template - auto operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a + b) +{ HB_PARTIALIZE(1); + template auto + operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a + b) } HB_FUNCOBJ (hb_add); struct -{ template auto operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a - b) } +{ HB_PARTIALIZE(1); + template auto + operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a - b) +} HB_FUNCOBJ (hb_sub); struct -{ template auto operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a * b) } +{ HB_PARTIALIZE(1); + template auto + operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a * b) +} HB_FUNCOBJ (hb_mul); struct -{ template auto operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a / b) } +{ HB_PARTIALIZE(1); + template auto + operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a / b) +} HB_FUNCOBJ (hb_div); struct -{ template auto operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a % b) } +{ HB_PARTIALIZE(1); + template auto + operator () (const T &a, const T2 &b) const HB_AUTO_RETURN (a % b) +} HB_FUNCOBJ (hb_mod); struct -{ template auto operator () (const T &a) const HB_AUTO_RETURN (+a) } +{ + template auto + operator () (const T &a) const HB_AUTO_RETURN (+a) +} HB_FUNCOBJ (hb_pos); struct -{ template auto operator () (const T &a) const HB_AUTO_RETURN (-a) } +{ + template auto + operator () (const T &a) const HB_AUTO_RETURN (-a) +} HB_FUNCOBJ (hb_neg); diff --git a/src/test-algs.cc b/src/test-algs.cc index 6906d9361..c34334ddd 100644 --- a/src/test-algs.cc +++ b/src/test-algs.cc @@ -77,8 +77,8 @@ main (int argc, char **argv) xp = hb_pair_t (nullptr, 1); xp = hb_pair_t (nullptr, 1); - assert (3 == hb_bind (hb_min, 3) (4)); - assert (3 == hb_bind (hb_min, 4) (3)); + assert (3 == hb_bind<0> (hb_min, 3) (4)); + assert (3 == hb_bind<0> (hb_min, 4) (3)); auto M0 = hb_bind<1> (hb_max, 0); assert (M0 (-2) == 0);