From e6b78003efbe02ba4542cadcc13bc1dd0b1d57b0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 30 Mar 2019 18:33:30 -0700 Subject: [PATCH] [vector] Add move semantics --- src/hb-vector.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 8793405..f689439 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -45,6 +45,13 @@ struct hb_vector_t alloc (o.length); hb_iter (o) | hb_sink (this); } + hb_vector_t (hb_vector_t &&o) + { + allocated = o.allocated; + length = o.length; + arrayZ_ = o.arrayZ_; + o.init (); + } ~hb_vector_t () { fini (); } unsigned int length; @@ -83,6 +90,15 @@ struct hb_vector_t hb_iter (o) | hb_sink (this); return *this; } + hb_vector_t& operator = (hb_vector_t &&o) + { + fini (); + allocated = o.allocated; + length = o.length; + arrayZ_ = o.arrayZ_; + o.init (); + return *this; + } const Type * arrayZ () const { return arrayZ_; } Type * arrayZ () { return arrayZ_; } -- 2.7.4