[iter] Adjust hb_copy() and use it

Untested.
This commit is contained in:
Behdad Esfahbod 2019-03-31 19:00:09 -07:00
parent ba4b7be455
commit 8a8d45b924
2 changed files with 6 additions and 9 deletions

View File

@ -585,14 +585,11 @@ hb_fill (C& c, const V &v)
*i = v; *i = v;
} }
template <typename S, typename D, template <typename S, typename D>
hb_enable_if (hb_is_iterator (S) && hb_is_iterator (D))> inline void
inline bool hb_copy (D&& id, S&& is)
hb_copy (D id, S is)
{ {
for (; id && is; ++id, ++is) hb_iter (id) | hb_sink (is);
*id = *is;
return !is;
} }

View File

@ -43,7 +43,7 @@ struct hb_vector_t
{ {
init (); init ();
alloc (o.length); alloc (o.length);
hb_iter (o) | hb_sink (this); hb_copy (o, *this);
} }
hb_vector_t (hb_vector_t &&o) hb_vector_t (hb_vector_t &&o)
{ {
@ -87,7 +87,7 @@ struct hb_vector_t
{ {
reset (); reset ();
alloc (o.length); alloc (o.length);
hb_iter (o) | hb_sink (this); hb_copy (o, *this);
return *this; return *this;
} }
hb_vector_t& operator = (hb_vector_t &&o) hb_vector_t& operator = (hb_vector_t &&o)