From 72dd5e34e0fc2902857c39cd4609d40b71fa4736 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 15 Feb 2019 16:11:32 -0800 Subject: [PATCH] [iter] Make hb_iter() into function-object --- src/hb-iter.hh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 7068aa4cc..e59d8993b 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -124,16 +124,26 @@ struct hb_iter_t /* TODO Change to function-object. */ -template -inline hb_iter_t (T) -hb_iter (const T& c) { return c.iter (); } - -/* Specialization for C arrays. */ template struct hb_array_t; -template inline hb_array_t -hb_iter (Type *array, unsigned int length) { return hb_array_t (array, length); } -template hb_array_t -hb_iter (Type (&array)[length]) { return hb_iter (array, length); } + +static const struct +{ + template + hb_iter_t (T) + operator () (const T& c) const + { return c.iter (); } + + /* Specialization for C arrays. */ + + template inline hb_array_t + operator () (Type *array, unsigned int length) const + { return hb_array_t (array, length); } + + template hb_array_t + operator () (Type (&array)[length]) const + { return hb_array_t (array, length); } + +} hb_iter HB_UNUSED; /* Mixin to fill in what the subclass doesn't provide. */