|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2018 Google, Inc. |
|
|
|
|
* Copyright © 2019 Google, Inc. |
|
|
|
|
* |
|
|
|
|
* This is part of HarfBuzz, a text shaping library. |
|
|
|
|
* |
|
|
|
@ -22,6 +23,7 @@ |
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
|
|
|
* |
|
|
|
|
* Google Author(s): Behdad Esfahbod |
|
|
|
|
* Facebook Author(s): Behdad Esfahbod |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#ifndef HB_ITER_HH |
|
|
|
@ -130,7 +132,7 @@ struct hb_iter_t |
|
|
|
|
|
|
|
|
|
template <typename> struct hb_array_t; |
|
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename T> |
|
|
|
|
hb_iter_t (T) |
|
|
|
@ -147,7 +149,7 @@ static const struct |
|
|
|
|
operator () (Type (&array)[length]) const |
|
|
|
|
{ return hb_array_t<Type> (array, length); } |
|
|
|
|
|
|
|
|
|
} hb_iter HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_iter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Mixin to fill in what the subclass doesn't provide. */ |
|
|
|
@ -298,13 +300,13 @@ struct hb_map_iter_factory_t |
|
|
|
|
private: |
|
|
|
|
Proj f; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Proj> |
|
|
|
|
hb_map_iter_factory_t<Proj> |
|
|
|
|
operator () (Proj&& f) const |
|
|
|
|
{ return hb_map_iter_factory_t<Proj> (f); } |
|
|
|
|
} hb_map HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_map); |
|
|
|
|
|
|
|
|
|
template <typename Iter, typename Pred, typename Proj, |
|
|
|
|
hb_enable_if (hb_is_iterator (Iter))> |
|
|
|
@ -342,14 +344,14 @@ struct hb_filter_iter_factory_t |
|
|
|
|
Pred p; |
|
|
|
|
Proj f; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Pred = decltype ((hb_bool)), |
|
|
|
|
typename Proj = decltype ((hb_identity))> |
|
|
|
|
hb_filter_iter_factory_t<Pred, Proj> |
|
|
|
|
operator () (Pred&& p = hb_bool, Proj&& f = hb_identity) const |
|
|
|
|
{ return hb_filter_iter_factory_t<Pred, Proj> (p, f); } |
|
|
|
|
} hb_filter HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_filter); |
|
|
|
|
|
|
|
|
|
template <typename Redu, typename InitT> |
|
|
|
|
struct hb_reduce_t |
|
|
|
@ -372,13 +374,13 @@ struct hb_reduce_t |
|
|
|
|
Redu r; |
|
|
|
|
InitT init_value; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Redu, typename InitT> |
|
|
|
|
hb_reduce_t<Redu, InitT> |
|
|
|
|
operator () (Redu&& r, InitT init_value) const |
|
|
|
|
{ return hb_reduce_t<Redu, InitT> (r, init_value); } |
|
|
|
|
} hb_reduce HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_reduce); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* hb_zip() */ |
|
|
|
@ -411,14 +413,14 @@ struct hb_zip_iter_t : |
|
|
|
|
A a; |
|
|
|
|
B b; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename A, typename B, |
|
|
|
|
hb_enable_if (hb_is_iterable (A) && hb_is_iterable (B))> |
|
|
|
|
hb_zip_iter_t<hb_iter_t (A), hb_iter_t (B)> |
|
|
|
|
operator () (A& a, B &b) const |
|
|
|
|
{ return hb_zip_iter_t<hb_iter_t (A), hb_iter_t (B)> (hb_iter (a), hb_iter (b)); } |
|
|
|
|
} hb_zip HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_zip); |
|
|
|
|
|
|
|
|
|
/* hb_enumerate */ |
|
|
|
|
|
|
|
|
@ -446,14 +448,14 @@ struct hb_enumerate_iter_t : |
|
|
|
|
unsigned i; |
|
|
|
|
Iter it; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Iterable, |
|
|
|
|
hb_enable_if (hb_is_iterable (Iterable))> |
|
|
|
|
hb_enumerate_iter_t<hb_iter_t (Iterable)> |
|
|
|
|
operator () (Iterable& it) const |
|
|
|
|
{ return hb_enumerate_iter_t<hb_iter_t (Iterable)> (hb_iter (it)); } |
|
|
|
|
} hb_enumerate HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_enumerate); |
|
|
|
|
|
|
|
|
|
/* hb_apply() */ |
|
|
|
|
|
|
|
|
@ -474,7 +476,7 @@ struct hb_apply_t |
|
|
|
|
private: |
|
|
|
|
Appl a; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Appl> hb_apply_t<Appl> |
|
|
|
|
operator () (Appl&& a) const |
|
|
|
@ -483,7 +485,7 @@ static const struct |
|
|
|
|
template <typename Appl> hb_apply_t<Appl&> |
|
|
|
|
operator () (Appl *a) const |
|
|
|
|
{ return hb_apply_t<Appl&> (*a); } |
|
|
|
|
} hb_apply HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_apply); |
|
|
|
|
|
|
|
|
|
/* hb_sink() */ |
|
|
|
|
|
|
|
|
@ -504,7 +506,7 @@ struct hb_sink_t |
|
|
|
|
private: |
|
|
|
|
Sink s; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Sink> hb_sink_t<Sink> |
|
|
|
|
operator () (Sink&& s) const |
|
|
|
@ -513,11 +515,11 @@ static const struct |
|
|
|
|
template <typename Sink> hb_sink_t<Sink&> |
|
|
|
|
operator () (Sink *s) const |
|
|
|
|
{ return hb_sink_t<Sink&> (*s); } |
|
|
|
|
} hb_sink HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_sink); |
|
|
|
|
|
|
|
|
|
/* hb-drain: hb_sink to void / blackhole / /dev/null. */ |
|
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Iter, |
|
|
|
|
hb_enable_if (hb_is_iterator (Iter))> |
|
|
|
@ -527,7 +529,7 @@ static const struct |
|
|
|
|
for (; it; ++it) |
|
|
|
|
(void) *it; |
|
|
|
|
} |
|
|
|
|
} hb_drain HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_drain); |
|
|
|
|
|
|
|
|
|
/* hb_unzip(): unzip and sink to two sinks. */ |
|
|
|
|
|
|
|
|
@ -553,7 +555,7 @@ struct hb_unzip_t |
|
|
|
|
Sink1 s1; |
|
|
|
|
Sink2 s2; |
|
|
|
|
}; |
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Sink1, typename Sink2> hb_unzip_t<Sink1, Sink2> |
|
|
|
|
operator () (Sink1&& s1, Sink2&& s2) const |
|
|
|
@ -562,12 +564,12 @@ static const struct |
|
|
|
|
template <typename Sink1, typename Sink2> hb_unzip_t<Sink1&, Sink2&> |
|
|
|
|
operator () (Sink1 *s1, Sink2 *s2) const |
|
|
|
|
{ return hb_unzip_t<Sink1&, Sink2&> (*s1, *s2); } |
|
|
|
|
} hb_unzip HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_unzip); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* hb-all, hb-any, hb-none. */ |
|
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Iterable, |
|
|
|
|
hb_enable_if (hb_is_iterable (Iterable))> |
|
|
|
@ -579,9 +581,8 @@ static const struct |
|
|
|
|
return false; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} hb_all HB_UNUSED; |
|
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
|
} HB_FUNCOBJ (hb_all); |
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Iterable, |
|
|
|
|
hb_enable_if (hb_is_iterable (Iterable))> |
|
|
|
@ -593,9 +594,8 @@ static const struct |
|
|
|
|
return true; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} hb_any HB_UNUSED; |
|
|
|
|
|
|
|
|
|
static const struct
|
|
|
|
|
} HB_FUNCOBJ (hb_any); |
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
template <typename Iterable, |
|
|
|
|
hb_enable_if (hb_is_iterable (Iterable))> |
|
|
|
@ -607,7 +607,7 @@ static const struct |
|
|
|
|
return false; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} hb_none HB_UNUSED; |
|
|
|
|
} HB_FUNCOBJ (hb_none); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Algorithms operating on iterators. |
|
|
|
|