[vector] Add some move and forwarding
This commit is contained in:
parent
7c9ceabcef
commit
4c4d3c3ed5
|
@ -151,7 +151,7 @@ struct hb_serialize_context_t
|
||||||
obj.head = tail;
|
obj.head = tail;
|
||||||
obj.tail = tail + len;
|
obj.tail = tail + len;
|
||||||
|
|
||||||
packed.push (obj);
|
packed.push (hb_move (obj));
|
||||||
|
|
||||||
/* TODO Handle error. */
|
/* TODO Handle error. */
|
||||||
if (unlikely (packed.in_error ()))
|
if (unlikely (packed.in_error ()))
|
||||||
|
|
|
@ -109,7 +109,7 @@ struct hb_vector_t
|
||||||
|
|
||||||
/* Sink interface. */
|
/* Sink interface. */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
hb_vector_t& operator << (const T& v) { push (v); return *this; }
|
hb_vector_t& operator << (T&& v) { push (hb_forward<T> (v)); return *this; }
|
||||||
|
|
||||||
hb_array_t< Type> as_array () { return hb_array (arrayZ(), length); }
|
hb_array_t< Type> as_array () { return hb_array (arrayZ(), length); }
|
||||||
hb_array_t<const Type> as_array () const { return hb_array (arrayZ(), length); }
|
hb_array_t<const Type> as_array () const { return hb_array (arrayZ(), length); }
|
||||||
|
@ -149,10 +149,10 @@ struct hb_vector_t
|
||||||
return &arrayZ()[length - 1];
|
return &arrayZ()[length - 1];
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Type *push (const T& v)
|
Type *push (T&& v)
|
||||||
{
|
{
|
||||||
Type *p = push ();
|
Type *p = push ();
|
||||||
*p = v;
|
*p = hb_forward<T> (v);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ struct hb_vector_t
|
||||||
Type pop ()
|
Type pop ()
|
||||||
{
|
{
|
||||||
if (!length) return Null(Type);
|
if (!length) return Null(Type);
|
||||||
return arrayZ()[--length];
|
return hb_move (arrayZ()[--length]); /* Does this move actually work? */
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove (unsigned int i)
|
void remove (unsigned int i)
|
||||||
|
|
Loading…
Reference in New Issue