[iter] Add hb_all, hb_any, hb_none
This commit is contained in:
parent
72dd5e34e0
commit
77060bcda2
|
@ -130,7 +130,7 @@ static const struct
|
|||
{
|
||||
template <typename T>
|
||||
hb_iter_t (T)
|
||||
operator () (const T& c) const
|
||||
operator () (T&& c) const
|
||||
{ return c.iter (); }
|
||||
|
||||
/* Specialization for C arrays. */
|
||||
|
@ -490,6 +490,50 @@ static const struct
|
|||
}
|
||||
} hb_drain HB_UNUSED;
|
||||
|
||||
/* hb-all, hb-any, hb-none. */
|
||||
|
||||
static const struct
|
||||
{
|
||||
template <typename Iterable,
|
||||
hb_enable_if (hb_is_iterable (Iterable))>
|
||||
bool
|
||||
operator () (Iterable&& c) const
|
||||
{
|
||||
for (auto it = hb_iter (c); it; ++it)
|
||||
if (!*it)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
} hb_all HB_UNUSED;
|
||||
|
||||
static const struct
|
||||
{
|
||||
template <typename Iterable,
|
||||
hb_enable_if (hb_is_iterable (Iterable))>
|
||||
bool
|
||||
operator () (Iterable&& c) const
|
||||
{
|
||||
for (auto it = hb_iter (c); it; ++it)
|
||||
if (it)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
} hb_any HB_UNUSED;
|
||||
|
||||
static const struct
|
||||
{
|
||||
template <typename Iterable,
|
||||
hb_enable_if (hb_is_iterable (Iterable))>
|
||||
bool
|
||||
operator () (Iterable&& c) const
|
||||
{
|
||||
for (auto it = hb_iter (c); it; ++it)
|
||||
if (it)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
} hb_none HB_UNUSED;
|
||||
|
||||
/*
|
||||
* Algorithms operating on iterators.
|
||||
*/
|
||||
|
|
|
@ -137,6 +137,8 @@ main (int argc, char **argv)
|
|||
|
||||
test_iterator (hb_zip (st, v));
|
||||
|
||||
hb_any (hb_zip (st, v));
|
||||
|
||||
hb_array_t<hb_vector_t<int> > pa;
|
||||
pa->as_array ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue