[iter] Make hb_iter() into function-object

This commit is contained in:
Behdad Esfahbod 2019-02-15 16:11:32 -08:00
parent 98be7bd77a
commit 72dd5e34e0
1 changed files with 19 additions and 9 deletions

View File

@ -124,16 +124,26 @@ struct hb_iter_t
/* TODO Change to function-object. */
template <typename T>
inline hb_iter_t (T)
hb_iter (const T& c) { return c.iter (); }
/* Specialization for C arrays. */
template <typename> struct hb_array_t;
template <typename Type> inline hb_array_t<Type>
hb_iter (Type *array, unsigned int length) { return hb_array_t<Type> (array, length); }
template <typename Type, unsigned int length> hb_array_t<Type>
hb_iter (Type (&array)[length]) { return hb_iter (array, length); }
static const struct
{
template <typename T>
hb_iter_t (T)
operator () (const T& c) const
{ return c.iter (); }
/* Specialization for C arrays. */
template <typename Type> inline hb_array_t<Type>
operator () (Type *array, unsigned int length) const
{ return hb_array_t<Type> (array, length); }
template <typename Type, unsigned int length> hb_array_t<Type>
operator () (Type (&array)[length]) const
{ return hb_array_t<Type> (array, length); }
} hb_iter HB_UNUSED;
/* Mixin to fill in what the subclass doesn't provide. */