From 39b9d63b014380d421cc9b94a49dd411c7a5aabf Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 24 Nov 2018 00:25:40 -0500 Subject: [PATCH] Add hb_static_size(T) --- src/hb-null.hh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/hb-null.hh b/src/hb-null.hh index c0cefc9a8..1583d5b90 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -44,6 +44,7 @@ /* The hard way... * https://stackoverflow.com/questions/7776448/sfinae-tried-with-bool-gives-compiler-error-template-argument-tvalue-invol */ + template struct _hb_bool_type {}; template @@ -58,6 +59,24 @@ struct hb_null_size { enum { value = _hb_null_size >::value }; }; #define hb_null_size(T) hb_null_size::value +/* This doesn't belong here, but since is copy/paste from above, put it here. */ + +template +struct _hb_static_size +{ enum { value = sizeof (T) }; }; +template +struct _hb_static_size > +{ enum { value = T::static_size }; }; + +template +struct hb_static_size +{ enum { value = _hb_static_size >::value }; }; +#define hb_static_size(T) hb_static_size::value + + +/* + * Null() + */ extern HB_INTERNAL hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)];