From 398b296f3b205daa8964de1a63957efeb59f6bdf Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 31 Aug 2019 12:44:24 -0500 Subject: [PATCH] [iter] Add hb_len() --- src/hb-iter.hh | 8 ++++++++ src/test-iter.cc | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index b8d2dd5c3..42ae0749b 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -175,6 +175,14 @@ struct } HB_FUNCOBJ (hb_iter); +struct +{ + template unsigned + operator () (T&& c) const + { return c.len (); } + +} +HB_FUNCOBJ (hb_len); /* Mixin to fill in what the subclass doesn't provide. */ template diff --git a/src/test-iter.cc b/src/test-iter.cc index 7ce6d8fde..10db97586 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -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);