diff --git a/src/hb-iter.hh b/src/hb-iter.hh index aa75267dc..e288509e4 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -748,6 +748,7 @@ struct ( hb_zip (hb_iota (start), it) ) } HB_FUNCOBJ (hb_enumerate); + struct { HB_PARTIALIZE(2); template + 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 diff --git a/src/test-iter.cc b/src/test-iter.cc index 10db97586..b5a4c8695 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -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);