[iter] Add hb_len()

This commit is contained in:
Behdad Esfahbod 2019-08-31 12:44:24 -05:00
parent 875131d478
commit 398b296f3b
2 changed files with 9 additions and 1 deletions

View File

@ -175,6 +175,14 @@ struct
}
HB_FUNCOBJ (hb_iter);
struct
{
template <typename T> unsigned
operator () (T&& c) const
{ return c.len (); }
}
HB_FUNCOBJ (hb_len);
/* Mixin to fill in what the subclass doesn't provide. */
template <typename iter_t, typename item_t = typename iter_t::__item_t__>

View File

@ -272,7 +272,7 @@ main (int argc, char **argv)
hb_repeat (7u);
hb_repeat (nullptr);
hb_repeat (vl);
assert ((hb_range (10) | hb_take (3)).len () == 3);
assert (hb_len (hb_range (10) | hb_take (3)) == 3);
assert (hb_range (9).len () == 9);
assert (hb_range (2, 9).len () == 7);
assert (hb_range (2, 9, 3).len () == 3);