diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 5c6988d79..3a7a6ab75 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -192,11 +192,15 @@ template <> struct hb_int_max : hb_integral_constant::value #define hb_is_trivially_copy_assignable(T) std::is_trivially_copy_assignable::value #define hb_is_trivially_constructible(T) std::is_trivially_constructible::value +#define hb_is_copy_constructible(T) std::is_copy_constructible::value +#define hb_is_trivially_copy_constructible(T) std::is_trivially_copy_constructible::value #define hb_is_trivially_destructible(T) std::is_trivially_destructible::value #endif diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 9cd67c32b..a5447a64d 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -61,7 +61,8 @@ struct hb_vector_t : std::conditional, hb_empty hb_vector_t (const hb_vector_t &o) : hb_vector_t () { alloc (o.length); - hb_copy (o, *this); + if (unlikely (in_error ())) return; + copy_vector (o); } hb_vector_t (hb_vector_t &&o) { @@ -109,7 +110,10 @@ struct hb_vector_t : std::conditional, hb_empty { reset (); alloc (o.length); - hb_copy (o, *this); + if (unlikely (in_error ())) return *this; + + copy_vector (o); + return *this; } hb_vector_t& operator = (hb_vector_t &&o) @@ -250,6 +254,28 @@ struct hb_vector_t : std::conditional, hb_empty } } + template + void + copy_vector (const hb_vector_t &other) + { + length = other.length; + hb_memcpy ((void *) arrayZ, (const void *) other.arrayZ, length * item_size); + } + template + void + copy_vector (const hb_vector_t &other) + { + length = 0; + while (length < other.length) + { + length++; + new (std::addressof (arrayZ[length - 1])) Type (other.arrayZ[length - 1]); + } + } + template void