diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 7358256c80493f065506e810fb227db71cd552d5..5ad839e2aa393cf578103d7e936b528ebac4df80 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -281,11 +281,11 @@ struct hb_is_iterator_of { enum { /* Range-based 'for' for iterables. */ template + hb_requires (hb_is_iterable (Iterable))> static inline auto begin (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable).begin ()) template + hb_requires (hb_is_iterable (Iterable))> static inline auto end (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable).end ()) /* begin()/end() are NOT looked up non-ADL. So each namespace must declare them. @@ -293,11 +293,11 @@ static inline auto end (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable). namespace OT { template + hb_requires (hb_is_iterable (Iterable))> static inline auto begin (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable).begin ()) template + hb_requires (hb_is_iterable (Iterable))> static inline auto end (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable).end ()) } @@ -308,14 +308,14 @@ static inline auto end (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable). */ template + hb_requires (hb_is_iterator (Lhs))> static inline auto operator | (Lhs lhs, const Rhs &rhs) HB_AUTO_RETURN (rhs (lhs)) /* hb_map(), hb_filter(), hb_reduce() */ template + hb_requires (hb_is_iterator (Iter))> struct hb_map_iter_t : hb_iter_t, decltype (hb_declval (Proj) (hb_declval (typename Iter::item_t)))> @@ -347,7 +347,7 @@ struct hb_map_iter_factory_t hb_map_iter_factory_t (Proj f) : f (f) {} template + hb_requires (hb_is_iterator (Iter))> hb_map_iter_t operator () (Iter it) const { return hb_map_iter_t (it, f); } @@ -365,7 +365,7 @@ struct HB_FUNCOBJ (hb_map); template + hb_requires (hb_is_iterator (Iter))> struct hb_filter_iter_t : hb_iter_with_fallback_t, typename Iter::item_t> @@ -394,7 +394,7 @@ struct hb_filter_iter_factory_t hb_filter_iter_factory_t (Pred p, Proj f) : p (p), f (f) {} template + hb_requires (hb_is_iterator (Iter))> hb_filter_iter_t operator () (Iter it) const { return hb_filter_iter_t (it, p, f); } @@ -419,7 +419,7 @@ struct hb_reduce_t hb_reduce_t (Redu r, InitT init_value) : r (r), init_value (init_value) {} template AccuT operator () (Iter it) const @@ -480,7 +480,7 @@ struct hb_zip_iter_t : struct { template + hb_requires (hb_is_iterable (A) && hb_is_iterable (B))> hb_zip_iter_t operator () (A& a, B &b) const { return hb_zip_iter_t (hb_iter (a), hb_iter (b)); } @@ -490,7 +490,7 @@ HB_FUNCOBJ (hb_zip); /* hb_enumerate */ template + hb_requires (hb_is_iterator (Iter))> struct hb_enumerate_iter_t : hb_iter_t, hb_pair_t> @@ -527,7 +527,7 @@ struct hb_enumerate_iter_t : struct { template + hb_requires (hb_is_iterable (Iterable))> hb_enumerate_iter_t operator () (Iterable& it) const { return hb_enumerate_iter_t (hb_iter (it)); } @@ -542,9 +542,8 @@ struct hb_apply_t hb_apply_t (Appl a) : a (a) {} template - void - operator () (Iter it) const + hb_requires (hb_is_iterator (Iter))> + void operator () (Iter it) const { for (; it; ++it) (void) hb_invoke (a, *it); @@ -573,9 +572,8 @@ struct hb_sink_t hb_sink_t (Sink&& s) : s (s) {} template - void - operator () (Iter it) const + hb_requires (hb_is_iterator (Iter))> + void operator () (Iter it) const { for (; it; ++it) s << *it; @@ -601,9 +599,8 @@ HB_FUNCOBJ (hb_sink); struct { template - void - operator () (Iter it) const + hb_requires (hb_is_iterator (Iter))> + void operator () (Iter it) const { for (; it; ++it) (void) *it; @@ -619,9 +616,8 @@ struct hb_unzip_t hb_unzip_t (Sink1&& s1, Sink2&& s2) : s1 (s1), s2 (s2) {} template - void - operator () (Iter it) const + hb_requires (hb_is_iterator (Iter))> + void operator () (Iter it) const { for (; it; ++it) { @@ -653,9 +649,8 @@ HB_FUNCOBJ (hb_unzip); struct { template - bool - operator () (Iterable&& c) const + hb_requires (hb_is_iterable (Iterable))> + bool operator () (Iterable&& c) const { for (auto it = hb_iter (c); it; ++it) if (!*it) @@ -667,9 +662,8 @@ HB_FUNCOBJ (hb_all); struct { template - bool - operator () (Iterable&& c) const + hb_requires (hb_is_iterable (Iterable))> + bool operator () (Iterable&& c) const { for (auto it = hb_iter (c); it; ++it) if (*it) @@ -681,9 +675,8 @@ HB_FUNCOBJ (hb_any); struct { template - bool - operator () (Iterable&& c) const + hb_requires (hb_is_iterable (Iterable))> + bool operator () (Iterable&& c) const { for (auto it = hb_iter (c); it; ++it) if (*it) @@ -698,7 +691,7 @@ HB_FUNCOBJ (hb_none); */ template + hb_requires (hb_is_iterable (C))> inline void hb_fill (C& c, const V &v) { diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index e2e562300d6becf0b468867d4f99f4641df1d241..5c015af3e775ed67c28b4c52b223ea7595b0a602 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -419,7 +419,7 @@ struct UnsizedArrayOf return_trace (true); } template + hb_requires (hb_is_iterator_of (Iterator, const Type))> bool serialize (hb_serialize_context_t *c, Iterator items) { TRACE_SERIALIZE (this); @@ -600,7 +600,7 @@ struct ArrayOf return_trace (true); } template + hb_requires (hb_is_iterator_of (Iterator, const Type))> bool serialize (hb_serialize_context_t *c, Iterator items) { TRACE_SERIALIZE (this); @@ -880,7 +880,7 @@ struct SortedArrayOf : ArrayOf return_trace (ret); } template + hb_requires (hb_is_sorted_iterator_of (Iterator, const Type))> bool serialize (hb_serialize_context_t *c, Iterator items) { TRACE_SERIALIZE (this); diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 17a03c85f5c4ab25c7e2292991e24cb0ed7bf534..05f84d2544091eb913c03f2ee9c767a5966352cc 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -797,7 +797,7 @@ struct CoverageFormat1 } template + hb_requires (hb_is_sorted_iterator_of (Iterator, const GlyphID))> bool serialize (hb_serialize_context_t *c, Iterator glyphs) { TRACE_SERIALIZE (this); @@ -866,7 +866,7 @@ struct CoverageFormat2 } template + hb_requires (hb_is_sorted_iterator_of (Iterator, const GlyphID))> bool serialize (hb_serialize_context_t *c, Iterator glyphs) { TRACE_SERIALIZE (this); @@ -1030,7 +1030,7 @@ struct Coverage } template + hb_requires (hb_is_sorted_iterator_of (Iterator, const GlyphID))> bool serialize (hb_serialize_context_t *c, Iterator glyphs) { TRACE_SERIALIZE (this); diff --git a/src/test-iter.cc b/src/test-iter.cc index afbcbe9b51052b7d1c0ae3c9e58040671ba65f4a..e8c6bda6b2f71fa101e50b981bb8abbd0ecf1e27 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -65,7 +65,7 @@ struct some_array_t template + hb_requires (hb_is_iterator (Iter))> static void test_iterator_non_default_constructable (Iter it) { @@ -92,7 +92,7 @@ test_iterator_non_default_constructable (Iter it) } template + hb_requires (hb_is_iterator (Iter))> static void test_iterator (Iter it) { @@ -103,7 +103,7 @@ test_iterator (Iter it) } template + hb_requires (hb_is_iterable (Iterable))> static void test_iterable (const Iterable &lst = Null(Iterable)) {