From fa35d3fd81c1ddb847cdd83556f817db9ef7f35b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 14 Feb 2019 14:04:05 -0800 Subject: [PATCH] [iter] Add hb_drain --- src/hb-iter.hh | 11 +++++++++++ src/test-iter.cc | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 2c885d676..730f6824c 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -430,6 +430,17 @@ static const struct { return hb_sink_t (*s); } } hb_sink HB_UNUSED; +static const struct +{ + template + void + operator () (Iter it) const + { + for (; it; ++it) + (void) *it; + } +} hb_drain HB_UNUSED; /* * Algorithms operating on iterators. diff --git a/src/test-iter.cc b/src/test-iter.cc index a96616369..d7e9a00ea 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -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;