From 357c7c611cc20f86c646bd2d392c243140f92d34 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 30 Mar 2019 18:13:57 -0700 Subject: [PATCH] [vector] Add copy constructor and assignment operator --- src/hb-vector.hh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index fd24950..5b1a83c 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -38,8 +38,13 @@ struct hb_vector_t typedef Type item_t; static constexpr unsigned item_size = hb_static_size (Type); - HB_NO_COPY_ASSIGN_TEMPLATE (hb_vector_t, Type); hb_vector_t () { init (); } + hb_vector_t (const hb_vector_t &o) + { + init (); + alloc (o.length); + hb_iter (o) | hb_sink (this); + } ~hb_vector_t () { fini (); } unsigned int length; @@ -69,6 +74,16 @@ struct hb_vector_t fini (); } + void reset () { resize (0); } + + hb_vector_t& operator = (const hb_vector_t &o) + { + reset (); + alloc (o.length); + hb_iter (o) | hb_sink (this); + return *this; + } + const Type * arrayZ () const { return arrayZ_; } Type * arrayZ () { return arrayZ_; } -- 2.7.4