提交 bb2a2065 编写于 作者: B Behdad Esfahbod

Assert that item-type of arrays have static size

上级 690d9eb8
...@@ -562,6 +562,8 @@ struct hb_bytes_t ...@@ -562,6 +562,8 @@ struct hb_bytes_t
template <typename Type> template <typename Type>
struct hb_array_t 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 (void) : arrayZ (nullptr), len (0) {}
inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
......
...@@ -345,6 +345,8 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null> ...@@ -345,6 +345,8 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
template <typename Type> template <typename Type>
struct UnsizedArrayOf struct UnsizedArrayOf
{ {
static_assert ((bool) (unsigned) hb_static_size (Type), "");
enum { item_size = Type::static_size }; enum { item_size = Type::static_size };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
...@@ -449,6 +451,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null> ...@@ -449,6 +451,8 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType, has_null>
template <typename Type, typename LenType=HBUINT16> template <typename Type, typename LenType=HBUINT16>
struct ArrayOf struct ArrayOf
{ {
static_assert ((bool) (unsigned) hb_static_size (Type), "");
enum { item_size = Type::static_size }; enum { item_size = Type::static_size };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType);
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
template <typename Type, unsigned int PreallocedCount=8> template <typename Type, unsigned int PreallocedCount=8>
struct hb_vector_t struct hb_vector_t
{ {
static_assert ((bool) (unsigned) hb_static_size (Type), "");
typedef Type ItemType; typedef Type ItemType;
enum { item_size = sizeof (Type) }; enum { item_size = sizeof (Type) };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册