[serialize] Take arguments in copy()

This commit is contained in:
Behdad Esfahbod committed 2019-05-02 14:14:33 -07:00
1 parent 273ed6127b
commit 88fdeeecc0
2 files changed
+9 -7

No files matched your search

+3 -3
View File
@@ -305,8 +305,8 @@ struct OffsetTo : Offset<OffsetType, has_null>
return ret;
}
template <typename T>
bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base)
template <typename T, typename ...Ts>
bool serialize_copy (hb_serialize_context_t *c, const T &src, const void *base, Ts &&...ds)
{
*this = 0;
if (has_null && &src == &Null (T))
@@ -314,7 +314,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
c->push ();
c->copy (src);
c->copy (src, hb_forward<Ts> (ds)...);
c->add_link (*this, c->pop_pack (), base);
}
+6 -4
View File
@@ -366,8 +366,9 @@ struct hb_serialize_context_t
return ret;
}
template <typename Type> auto
_copy (const Type &obj, hb_priority<1>) const HB_RETURN (Type *, obj.copy (this))
template <typename Type, typename ...Ts> auto
_copy (const Type &obj, hb_priority<1>, Ts &&...ds) const HB_RETURN
(Type *, obj.copy (this, hb_forward<Ts> (ds)...))
template <typename Type> auto
_copy (const Type &obj, hb_priority<0>) const -> decltype (&(obj = obj))
@@ -380,8 +381,9 @@ struct hb_serialize_context_t
/* Like embed, but active: calls obj.operator=() or obj.copy() to transfer data
* instead of memcpy(). */
template <typename Type>
Type *copy (const Type &obj) { return _copy (obj, hb_prioritize); }
template <typename Type, typename ...Ts>
Type *copy (const Type &obj, Ts &&...ds)
{ return _copy (obj, hb_prioritize, hb_forward<Ts> (ds)...); }
template <typename Type>
hb_serialize_context_t &operator << (const Type &obj) { embed (obj); return *this; }