From: Behdad Esfahbod Date: Tue, 16 Apr 2019 14:50:22 +0000 (-0400) Subject: [meta] Add hb_invoke() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8e763fd7140b3e298863e04053ec0f3c73a6a70;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [meta] Add hb_invoke() --- diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 1cda64f..1460e72 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -70,6 +70,29 @@ struct operator () (const T& v) const { return bool (v); } } HB_FUNCOBJ (hb_bool); + +struct +{ + private: + + // TODO Add overload to for pointer-to-member-function + + template auto + impl (Appl&& a, Val &&v, hb_priority<1>) const HB_AUTO_RETURN_EXPR (a (hb_forward (v))) + + template auto + impl (Appl&& a, Val &&v, hb_priority<0>) const HB_AUTO_RETURN_EXPR ((*a) (hb_forward (v))) + + public: + + template auto + operator () (Appl&& a, Val &&v) const HB_AUTO_RETURN_EXPR ( + impl (hb_forward (a), + hb_forward (v), + hb_prioritize) + ) +} HB_FUNCOBJ (hb_invoke); + struct { private: @@ -81,7 +104,10 @@ struct impl (Pred&& p, Val &&v, hb_priority<1>) const HB_AUTO_RETURN_EXPR (p.has (v)) template auto - impl (Pred&& p, Val &&v, hb_priority<0>) const HB_AUTO_RETURN_EXPR (p (v)) + impl (Pred&& p, Val &&v, hb_priority<0>) const HB_AUTO_RETURN_EXPR ( + hb_invoke (hb_forward (p), + hb_forward (v)) + ) public: @@ -104,7 +130,10 @@ struct impl (Proj&& f, Val &&v, hb_priority<1>) const HB_AUTO_RETURN_EXPR (f.get (hb_forward (v))) template auto - impl (Proj&& f, Val &&v, hb_priority<2>) const HB_AUTO_RETURN_EXPR (f (hb_forward (v))) + impl (Proj&& f, Val &&v, hb_priority<2>) const HB_AUTO_RETURN_EXPR ( + hb_invoke (hb_forward (f), + hb_forward (v)) + ) public: @@ -116,6 +145,7 @@ struct ) } HB_FUNCOBJ (hb_get); + template struct hb_pair_t { diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 719987d..7e76733 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -471,7 +471,7 @@ struct hb_apply_t operator () (Iter it) const { for (; it; ++it) - a (*it); + (void) hb_invoke (a, *it); } private: