diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-11-29 12:18:14 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-11-29 12:18:14 -0500 |
commit | 282ce7230b8bd8ad65c408cdaf1499504038247d (patch) | |
tree | 6aeed3ced533313e4df22adff5054698fa96a072 | |
parent | dc41ecef85b094b30c612113606597b91c55351c (diff) |
Fix "typename outside template" issues
Nothing an extra template class wouldn't fix...
Fixes https://github.com/harfbuzz/harfbuzz/issues/1419
-rw-r--r-- | src/hb-null.hh | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/hb-null.hh b/src/hb-null.hh index 1583d5b9..dde4b2e9 100644 --- a/src/hb-null.hh +++ b/src/hb-null.hh @@ -77,6 +77,7 @@ struct hb_static_size /* * 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)]; @@ -86,7 +87,13 @@ static inline Type const & Null (void) { static_assert (hb_null_size (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); return *reinterpret_cast<Type const *> (_hb_NullPool); } -#define Null(Type) Null<typename hb_remove_const (typename hb_remove_reference (Type))> () +template <typename QType> +struct NullHelper +{ + typedef typename hb_remove_const (typename hb_remove_reference (QType)) Type; + static inline const Type & get_null (void) { return Null<Type> (); } +}; +#define Null(Type) NullHelper<Type>::get_null () /* Specializations for arbitrary-content Null objects expressed in bytes. */ #define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \ @@ -129,17 +136,23 @@ static inline Type& Crap (void) { memcpy (obj, &Null(Type), sizeof (*obj)); return *obj; } -#define Crap(Type) Crap<typename hb_remove_const (typename hb_remove_reference (Type))> () +template <typename QType> +struct CrapHelper +{ + typedef typename hb_remove_const (typename hb_remove_reference (QType)) Type; + static inline Type & get_crap (void) { return Crap<Type> (); } +}; +#define Crap(Type) CrapHelper<Type>::get_crap () template <typename Type> -struct CrapOrNull { +struct CrapOrNullHelper { static inline Type & get (void) { return Crap(Type); } }; template <typename Type> -struct CrapOrNull<const Type> { - static inline Type const & get (void) { return Null(Type); } +struct CrapOrNullHelper<const Type> { + static inline const Type & get (void) { return Null(Type); } }; -#define CrapOrNull(Type) CrapOrNull<Type>::get () +#define CrapOrNull(Type) CrapOrNullHelper<Type>::get () /* |