[iter] Adjust hb_copy() and use it
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 1 Apr 2019 02:00:09 +0000 (19:00 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 1 Apr 2019 02:00:09 +0000 (19:00 -0700)
Untested.

src/hb-iter.hh
src/hb-vector.hh

index 203a3c7..18b9c4a 100644 (file)
@@ -585,14 +585,11 @@ hb_fill (C& c, const V &v)
     *i = v;
 }
 
-template <typename S, typename D,
-         hb_enable_if (hb_is_iterator (S) && hb_is_iterator (D))>
-inline bool
-hb_copy (D id, S is)
+template <typename S, typename D>
+inline void
+hb_copy (D&& id, S&& is)
 {
-  for (; id && is; ++id, ++is)
-    *id = *is;
-  return !is;
+  hb_iter (id) | hb_sink (is);
 }
 
 
index 4621b51..b5ac738 100644 (file)
@@ -43,7 +43,7 @@ struct hb_vector_t
   {
     init ();
     alloc (o.length);
-    hb_iter (o) | hb_sink (this);
+    hb_copy (o, *this);
   }
   hb_vector_t (hb_vector_t &&o)
   {
@@ -87,7 +87,7 @@ struct hb_vector_t
   {
     reset ();
     alloc (o.length);
-    hb_iter (o) | hb_sink (this);
+    hb_copy (o, *this);
     return *this;
   }
   hb_vector_t& operator = (hb_vector_t &&o)