From b6f29bf14153cac51b218e3aaba9e1b3aa747a8c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 2 Apr 2019 18:12:01 -0700 Subject: [PATCH] [iter] Accept pointers in hb_iter() No idea how to avoid dupicating code. Was hoping hb_deref_pointer() would do it, but looks like a pointer can't bind to a universal reference T&&. Humm. --- src/hb-iter.hh | 5 +++++ src/test-iter.cc | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index f23904c22..9a3c2f43f 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -137,6 +137,11 @@ static const struct operator () (T&& c) const { return c.iter (); } + template + hb_iter_t (T) + operator () (T* c) const + { return c->iter (); } + /* Specialization for C arrays. */ template inline hb_array_t diff --git a/src/test-iter.cc b/src/test-iter.cc index 675bbe397..dcfdd1183 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -106,6 +106,9 @@ main (int argc, char **argv) int dst[20]; hb_vector_t v; + hb_iter (v); + hb_iter (&v); + array_iter_t s (src); /* Implicit conversion from static array. */ array_iter_t s2 (v); /* Implicit conversion from vector. */ array_iter_t t (dst);