diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 0940dc53c..2249e128d 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -539,19 +539,24 @@ struct hb_bytes_t unsigned int len; }; -template +template struct hb_array_t { inline hb_array_t (void) : arrayZ (nullptr), len (0) {} - inline hb_array_t (T *array_, unsigned int len_) : arrayZ (array_), len (len_) {} + inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {} - inline T& operator [] (unsigned int i) const + inline Type& operator [] (unsigned int i) const { - if (unlikely (i >= len)) return Null(T); + if (unlikely (i >= len)) return Null(Type); return arrayZ[i]; } - inline hb_array_t sub_array (unsigned int start_offset, unsigned int seg_count) const + inline unsigned int get_size (void) { return len * sizeof (Type); } + + template inline operator T * (void) { return arrayZ; } + template inline operator const T * (void) const { return arrayZ; } + + inline hb_array_t sub_array (unsigned int start_offset, unsigned int seg_count) const { unsigned int count = len; if (unlikely (start_offset > count)) @@ -559,17 +564,17 @@ struct hb_array_t else count -= start_offset; count = MIN (count, seg_count); - return hb_array_t (arrayZ + start_offset, count); + return hb_array_t (arrayZ + start_offset, count); } inline hb_bytes_t as_bytes (void) const { - return hb_bytes_t (arrayZ, len * sizeof (T)); + return hb_bytes_t (arrayZ, len * sizeof (Type)); } inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } - T *arrayZ; + Type *arrayZ; unsigned int len; };