From 58ad357951a732f05d9680573d00a4764171a9dd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 29 Mar 2019 20:05:19 -0700 Subject: [PATCH] [vector] Accept all types in push(...) Let assignment operator worry about conversion. --- src/hb-vector.hh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 6275875..0354845 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -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 + 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 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 + Type *push (const T& v) { Type *p = push (); *p = v; -- 2.7.4