Assert that item-type of arrays have static size

This commit is contained in:
Behdad Esfahbod 2018-11-24 00:31:40 -05:00
parent 690d9eb83d
commit bb2a206508
3 changed files with 8 additions and 0 deletions

View File

@ -562,6 +562,8 @@ struct hb_bytes_t
template <typename Type>
struct hb_array_t
{
static_assert ((bool) (unsigned) hb_static_size (Type), "");
inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}

View File

@ -345,6 +345,8 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
template <typename Type>
struct UnsizedArrayOf
{
static_assert ((bool) (unsigned) hb_static_size (Type), "");
enum { item_size = Type::static_size };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
@ -449,6 +451,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null>
template <typename Type, typename LenType=HBUINT16>
struct ArrayOf
{
static_assert ((bool) (unsigned) hb_static_size (Type), "");
enum { item_size = Type::static_size };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType);

View File

@ -34,6 +34,8 @@
template <typename Type, unsigned int PreallocedCount=8>
struct hb_vector_t
{
static_assert ((bool) (unsigned) hb_static_size (Type), "");
typedef Type ItemType;
enum { item_size = sizeof (Type) };