[vector] Accept all types in push(...)

Let assignment operator worry about conversion.
This commit is contained in:
Behdad Esfahbod 2019-03-29 20:05:19 -07:00
parent 489faf826c
commit 58ad357951
1 changed files with 4 additions and 2 deletions

View File

@ -90,7 +90,8 @@ struct hb_vector_t
explicit operator bool () const { return length; }
/* Sink interface. */
hb_vector_t& operator << (const Type &v) { push (v); return *this; }
template <typename T>
hb_vector_t& operator << (const T& v) { push (v); return *this; }
hb_array_t< Type> as_array () { return hb_array (arrayZ(), length); }
hb_array_t<const Type> as_array () const { return hb_array (arrayZ(), length); }
@ -129,7 +130,8 @@ struct hb_vector_t
return &Crap(Type);
return &arrayZ()[length - 1];
}
Type *push (const Type& v)
template <typename T>
Type *push (const T& v)
{
Type *p = push ();
*p = v;