[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.
This commit is contained in:
Behdad Esfahbod 2019-04-02 18:12:01 -07:00
parent fc24bb9046
commit b6f29bf141
2 changed files with 8 additions and 0 deletions

View File

@ -137,6 +137,11 @@ static const struct
operator () (T&& c) const operator () (T&& c) const
{ return c.iter (); } { return c.iter (); }
template <typename T>
hb_iter_t (T)
operator () (T* c) const
{ return c->iter (); }
/* Specialization for C arrays. */ /* Specialization for C arrays. */
template <typename Type> inline hb_array_t<Type> template <typename Type> inline hb_array_t<Type>

View File

@ -106,6 +106,9 @@ main (int argc, char **argv)
int dst[20]; int dst[20];
hb_vector_t<int> v; hb_vector_t<int> v;
hb_iter (v);
hb_iter (&v);
array_iter_t<const int> s (src); /* Implicit conversion from static array. */ array_iter_t<const int> s (src); /* Implicit conversion from static array. */
array_iter_t<const int> s2 (v); /* Implicit conversion from vector. */ array_iter_t<const int> s2 (v); /* Implicit conversion from vector. */
array_iter_t<int> t (dst); array_iter_t<int> t (dst);