diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 0ecd3c6b6..f4a9a5e87 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -231,17 +231,31 @@ struct FixedVersion * Use: (base+offset) */ +template +struct _hb_has_null +{ + static inline const Type *get_null (void) { return nullptr; } + static inline Type *get_crap (void) { return nullptr; } +}; +template +struct _hb_has_null +{ + static inline const Type *get_null (void) { return &Null(Type); } + static inline Type *get_crap (void) { return &Crap(Type); } +}; + template struct OffsetTo : Offset { inline const Type& operator () (const void *base) const { - if (unlikely (this->is_null ())) return Null (Type); + if (unlikely (this->is_null ())) return *_hb_has_null::get_null (); return StructAtOffset (base, *this); } inline Type& operator () (void *base) const { if (unlikely (this->is_null ())) return Crap (Type); + if (unlikely (this->is_null ())) return *_hb_has_null::get_crap (); return StructAtOffset (base, *this); }