From 849a0f1758b67eb3b4d864047b9df671e76404a5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 29 Jan 2019 17:10:19 -0800 Subject: [PATCH] [iter] Add hb_iter_with_fallback_t instead --- src/hb-array.hh | 5 +---- src/hb-iter.hh | 29 +++++++++++++---------------- src/hb-ot-layout-common.hh | 5 +---- src/hb-set.hh | 5 +---- src/test-iter.cc | 5 +---- 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/hb-array.hh b/src/hb-array.hh index 82b3f1aac..ab453f5a2 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -37,10 +37,7 @@ template struct hb_sorted_array_t; template -struct hb_array_t : - hb_iter_with_mixin_t, - Type&> +struct hb_array_t : hb_iter_with_fallback_t, Type&> { /* * Constructors. diff --git a/src/hb-iter.hh b/src/hb-iter.hh index c69da3d8f..305d9eaec 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -132,19 +132,6 @@ 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 @@ -178,6 +165,17 @@ struct hb_iter_fallback_mixin_t void operator = (const hb_iter_fallback_mixin_t &o HB_UNUSED) {} }; +template +struct hb_iter_with_fallback_t : + hb_iter_t, + hb_iter_fallback_mixin_t +{ + protected: + hb_iter_with_fallback_t () {} + hb_iter_with_fallback_t (const hb_iter_with_fallback_t &o HB_UNUSED) {} + void operator = (const hb_iter_with_fallback_t &o HB_UNUSED) {} +}; + /* * Meta-programming predicates. */ @@ -283,9 +281,8 @@ hb_map (Proj&& f) template struct hb_filter_iter_t : - hb_iter_with_mixin_t, - typename Iter::item_t> + hb_iter_with_fallback_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 09232e360..f29f87542 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1120,10 +1120,7 @@ struct Coverage } } - struct iter_t : - hb_iter_with_mixin_t + struct iter_t : hb_iter_with_fallback_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 b1198992d..5d48412db 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -682,10 +682,7 @@ struct hb_set_t /* * Iterator implementation. */ - struct iter_t : - hb_iter_with_mixin_t + struct iter_t : hb_iter_with_fallback_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 83f0bef69..cd94be845 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -33,10 +33,7 @@ template -struct array_iter_t : - hb_iter_with_mixin_t, - T&> +struct array_iter_t : hb_iter_with_fallback_t, T&> { array_iter_t (hb_array_t arr_) : arr (arr_) {}