From 4d40ed9d1a7a4f18af6710a1b8ba90257b8456a0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 29 Jan 2019 13:55:23 -0800 Subject: [PATCH] [iter] Add hb_iter_with_mixin_t<> --- src/hb-array.hh | 5 +++-- src/hb-iter.hh | 18 ++++++++++++++++-- src/hb-ot-layout-common.hh | 5 +++-- src/hb-set.hh | 5 +++-- src/test-iter.cc | 5 +++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index fc1bdc854..82b3f1aac 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -38,8 +38,9 @@ struct hb_sorted_array_t; template struct hb_array_t : - hb_iter_t, Type&>, - hb_iter_fallback_mixin_t, Type&> + hb_iter_with_mixin_t, + Type&> { /* * Constructors. diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 8052166d6..c69da3d8f 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -132,6 +132,19 @@ template hb_array_t hb_iter (Type (&array)[length]) { return hb_iter (array, length); } +template class mixin_t, + typename iter_t, + typename item_t = typename iter_t::__item_t__> +struct hb_iter_with_mixin_t : + hb_iter_t, + mixin_t +{ + protected: + hb_iter_with_mixin_t () {} + hb_iter_with_mixin_t (const hb_iter_with_mixin_t &o HB_UNUSED) {} + void operator = (const hb_iter_with_mixin_t &o HB_UNUSED) {} +}; + /* Mixin to fill in what the subclass doesn't provide. */ template struct hb_iter_fallback_mixin_t @@ -270,8 +283,9 @@ hb_map (Proj&& f) template struct hb_filter_iter_t : - hb_iter_t, typename Iter::item_t>, - hb_iter_fallback_mixin_t, typename Iter::item_t> + hb_iter_with_mixin_t, + typename Iter::item_t> { hb_filter_iter_t (const Iter& it_, Pred&& p, Proj&& f) : it (it_), p (p), f (f) { while (it && !p (f (*it))) ++it; } diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 21eb5e8d6..09232e360 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1121,8 +1121,9 @@ struct Coverage } struct iter_t : - hb_iter_t, - hb_iter_fallback_mixin_t + hb_iter_with_mixin_t { static constexpr bool is_sorted_iterator = true; iter_t (const Coverage &c_ = Null(Coverage)) diff --git a/src/hb-set.hh b/src/hb-set.hh index b3e4907d6..b1198992d 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -683,8 +683,9 @@ struct hb_set_t * Iterator implementation. */ struct iter_t : - hb_iter_t, - hb_iter_fallback_mixin_t + hb_iter_with_mixin_t { static constexpr bool is_sorted_iterator = true; iter_t (const hb_set_t &s_ = Null(hb_set_t)) : diff --git a/src/test-iter.cc b/src/test-iter.cc index 4da8c9d13..83f0bef69 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -34,8 +34,9 @@ template struct array_iter_t : - hb_iter_t, T&>, - hb_iter_fallback_mixin_t, T&> + hb_iter_with_mixin_t, + T&> { array_iter_t (hb_array_t arr_) : arr (arr_) {}