[null] Add hb_has_null_size() and hb_has_min_size()

This commit is contained in:
Behdad Esfahbod 2022-07-15 16:02:58 -06:00
parent c8908f92d7
commit e1d2facd53
1 changed files with 18 additions and 0 deletions

View File

@ -39,6 +39,24 @@
#define HB_NULL_POOL_SIZE 448
template <typename T, typename>
struct _hb_has_min_size : hb_false_type {};
template <typename T>
struct _hb_has_min_size<T, hb_void_t<decltype (T::min_size)>>
: hb_true_type {};
template <typename T>
using hb_has_min_size = _hb_has_min_size<T, void>;
#define hb_has_min_size(T) hb_has_min_size<T>::value
template <typename T, typename>
struct _hb_has_null_size : hb_false_type {};
template <typename T>
struct _hb_has_null_size<T, hb_void_t<decltype (T::null_size)>>
: hb_true_type {};
template <typename T>
using hb_has_null_size = _hb_has_null_size<T, void>;
#define hb_has_null_size(T) hb_has_null_size<T>::value
/* Use SFINAE to sniff whether T has min_size; in which case return the larger
* of sizeof(T) and T::null_size, otherwise return sizeof(T).
*