diff options
Diffstat (limited to 'thirdparty/harfbuzz/src/hb-iter.hh')
-rw-r--r-- | thirdparty/harfbuzz/src/hb-iter.hh | 99 |
1 files changed, 92 insertions, 7 deletions
diff --git a/thirdparty/harfbuzz/src/hb-iter.hh b/thirdparty/harfbuzz/src/hb-iter.hh index b8c4472636..ad2e45e3c5 100644 --- a/thirdparty/harfbuzz/src/hb-iter.hh +++ b/thirdparty/harfbuzz/src/hb-iter.hh @@ -162,7 +162,7 @@ struct { template <typename T> hb_iter_type<T> operator () (T&& c) const - { return hb_deref (hb_forward<T> (c)).iter (); } + { return hb_deref (std::forward<T> (c)).iter (); } /* Specialization for C arrays. */ @@ -353,7 +353,7 @@ static inline auto end (Iterable&& iterable) HB_AUTO_RETURN (hb_iter (iterable). template <typename Lhs, typename Rhs, hb_requires (hb_is_iterator (Lhs))> static inline auto -operator | (Lhs&& lhs, Rhs&& rhs) HB_AUTO_RETURN (hb_forward<Rhs> (rhs) (hb_forward<Lhs> (lhs))) +operator | (Lhs&& lhs, Rhs&& rhs) HB_AUTO_RETURN (std::forward<Rhs> (rhs) (std::forward<Lhs> (lhs))) /* hb_map(), hb_filter(), hb_reduce() */ @@ -581,6 +581,91 @@ struct } HB_FUNCOBJ (hb_zip); +/* hb_concat() */ + +template <typename A, typename B> +struct hb_concat_iter_t : + hb_iter_t<hb_concat_iter_t<A, B>, typename A::item_t> +{ + hb_concat_iter_t () {} + hb_concat_iter_t (A& a, B& b) : a (a), b (b) {} + hb_concat_iter_t (const A& a, const B& b) : a (a), b (b) {} + + + typedef typename A::item_t __item_t__; + static constexpr bool is_random_access_iterator = + A::is_random_access_iterator && + B::is_random_access_iterator; + static constexpr bool is_sorted_iterator = false; + + __item_t__ __item__ () const + { + if (!a) + return *b; + return *a; + } + + __item_t__ __item_at__ (unsigned i) const + { + unsigned a_len = a.len (); + if (i < a_len) + return a[i]; + return b[i - a_len]; + } + + bool __more__ () const { return bool (a) || bool (b); } + + unsigned __len__ () const { return a.len () + b.len (); } + + void __next__ () + { + if (a) + ++a; + else + ++b; + } + + void __forward__ (unsigned n) + { + if (!n) return; + if (!is_random_access_iterator) { + while (n-- && *this) { + (*this)++; + } + return; + } + + unsigned a_len = a.len (); + if (n > a_len) { + n -= a_len; + a.__forward__ (a_len); + b.__forward__ (n); + } else { + a.__forward__ (n); + } + } + + hb_concat_iter_t __end__ () const { return hb_concat_iter_t (a.end (), b.end ()); } + bool operator != (const hb_concat_iter_t& o) const + { + return a != o.a + || b != o.b; + } + + private: + A a; + B b; +}; +struct +{ HB_PARTIALIZE(2); + template <typename A, typename B, + hb_requires (hb_is_iterable (A) && hb_is_iterable (B))> + hb_concat_iter_t<hb_iter_type<A>, hb_iter_type<B>> + operator () (A&& a, B&& b) const + { return hb_concat_iter_t<hb_iter_type<A>, hb_iter_type<B>> (hb_iter (a), hb_iter (b)); } +} +HB_FUNCOBJ (hb_concat); + /* hb_apply() */ template <typename Appl> @@ -674,8 +759,8 @@ struct hb_iota_iter_t : template <typename S2 = S> auto inc (hb_type_identity<S2> s, hb_priority<1>) - -> hb_void_t<decltype (hb_invoke (hb_forward<S2> (s), hb_declval<T&> ()))> - { v = hb_invoke (hb_forward<S2> (s), v); } + -> hb_void_t<decltype (hb_invoke (std::forward<S2> (s), hb_declval<T&> ()))> + { v = hb_invoke (std::forward<S2> (s), v); } void inc (S s, hb_priority<0>) @@ -874,7 +959,7 @@ struct Proj&& f = hb_identity) const { for (auto it = hb_iter (c); it; ++it) - if (!hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it))) + if (!hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it))) return false; return true; } @@ -891,7 +976,7 @@ struct Proj&& f = hb_identity) const { for (auto it = hb_iter (c); it; ++it) - if (hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it))) + if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it))) return true; return false; } @@ -908,7 +993,7 @@ struct Proj&& f = hb_identity) const { for (auto it = hb_iter (c); it; ++it) - if (hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it))) + if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it))) return false; return true; } |