[iter] Add hb_drain

This commit is contained in:
Behdad Esfahbod 2019-02-14 14:04:05 -08:00
parent f4cfd6b6ad
commit fa35d3fd81
2 changed files with 17 additions and 1 deletions

View File

@ -430,6 +430,17 @@ static const struct
{ return hb_sink_t<Sink&> (*s); }
} hb_sink HB_UNUSED;
static const struct
{
template <typename Iter,
hb_enable_if (hb_is_iterator (Iter))>
void
operator () (Iter it) const
{
for (; it; ++it)
(void) *it;
}
} hb_drain HB_UNUSED;
/*
* Algorithms operating on iterators.

View File

@ -149,7 +149,12 @@ main (int argc, char **argv)
;
+ hb_iter (src)
| hb_apply (&st);
| hb_apply (&st)
;
+ hb_iter (src)
| hb_drain
;
t << 1;
long vl;