[iter] Add hb_chop()
This commit is contained in:
parent
5828d8e83c
commit
67ec9fa9e4
|
@ -748,6 +748,7 @@ struct
|
|||
( hb_zip (hb_iota (start), it) )
|
||||
}
|
||||
HB_FUNCOBJ (hb_enumerate);
|
||||
|
||||
struct
|
||||
{ HB_PARTIALIZE(2);
|
||||
template <typename Iterable,
|
||||
|
@ -767,6 +768,19 @@ struct
|
|||
}
|
||||
HB_FUNCOBJ (hb_take);
|
||||
|
||||
struct
|
||||
{ HB_PARTIALIZE(2);
|
||||
template <typename Iter,
|
||||
hb_requires (hb_is_iterator (Iter))>
|
||||
auto operator () (Iter it, unsigned count) const HB_AUTO_RETURN
|
||||
(
|
||||
+ hb_iota (it, hb_partial<2> (hb_add, count))
|
||||
| hb_map (hb_partial<2> (hb_take, count))
|
||||
| hb_take ((hb_len (it) + count - 1) / count)
|
||||
)
|
||||
}
|
||||
HB_FUNCOBJ (hb_chop);
|
||||
|
||||
/* hb_sink() */
|
||||
|
||||
template <typename Sink>
|
||||
|
|
|
@ -271,7 +271,7 @@ main (int argc, char **argv)
|
|||
hb_range ();
|
||||
hb_repeat (7u);
|
||||
hb_repeat (nullptr);
|
||||
hb_repeat (vl);
|
||||
hb_repeat (vl) | hb_chop (3);
|
||||
assert (hb_len (hb_range (10) | hb_take (3)) == 3);
|
||||
assert (hb_range (9).len () == 9);
|
||||
assert (hb_range (2, 9).len () == 7);
|
||||
|
|
Loading…
Reference in New Issue