diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 232467e49..93677435b 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -50,7 +50,7 @@ struct { private: template auto - impl (const T& v, hb_priority<1>) const HB_AUTO_RETURN (hb_deref_pointer (v).hash ()) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref_pointer (v).hash ()) template auto @@ -63,7 +63,7 @@ struct public: template auto - operator () (const T& v) const HB_AUTO_RETURN ((uint32_t) impl (v, hb_prioritize)) + operator () (const T& v) const HB_RETURN (uint32_t, impl (v, hb_prioritize)) } HB_FUNCOBJ (hb_hash); struct @@ -114,11 +114,10 @@ struct public: template auto - operator () (Pred&& p, Val &&v) const HB_AUTO_RETURN - ( - (bool) impl (hb_forward (p), - hb_forward (v), - hb_prioritize) + operator () (Pred&& p, Val &&v) const HB_RETURN (bool, + impl (hb_forward (p), + hb_forward (v), + hb_prioritize) ) } HB_FUNCOBJ (hb_has); diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 4a141ce92..0dcf79320 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -34,8 +34,27 @@ * C++ template meta-programming & fundamentals used with them. */ +/* Void! For when we need a expression-type of void. */ +struct hb_void_t { typedef void value; }; + +/* Void meta-function ala std::void_t + * https://en.cppreference.com/w/cpp/types/void_t */ +template struct _hb_void_tt { typedef void type; }; +template using hb_void_tt = typename _hb_void_tt::type; + +template struct _hb_head_tt { typedef Head type; }; +template using hb_head_tt = typename _hb_head_tt::type; + +/* Bool! For when we need to evaluate type-dependent expressions + * in a template argument. */ +template struct hb_bool_tt { enum { value = b }; }; +typedef hb_bool_tt hb_true_t; +typedef hb_bool_tt hb_false_t; + + /* Function overloading SFINAE and priority. */ +#define HB_RETURN(Ret, E) -> hb_head_tt { return (E); } #define HB_AUTO_RETURN(E) -> decltype ((E)) { return (E); } #define HB_VOID_RETURN(E) -> hb_void_tt { (E); } @@ -45,6 +64,7 @@ template <> struct hb_priority<0> {}; #define HB_FUNCOBJ(x) static_const x HB_UNUSED + struct { template @@ -98,20 +118,6 @@ struct } HB_FUNCOBJ (hb_deref_pointer); -/* Void! For when we need a expression-type of void. */ -struct hb_void_t { typedef void value; }; - -/* Void meta-function ala std::void_t - * https://en.cppreference.com/w/cpp/types/void_t */ -template struct _hb_void_tt { typedef void type; }; -template using hb_void_tt = typename _hb_void_tt::type; - -/* Bool! For when we need to evaluate type-dependent expressions - * in a template argument. */ -template struct hb_bool_tt { enum { value = b }; }; -typedef hb_bool_tt hb_true_t; -typedef hb_bool_tt hb_false_t; - template struct hb_enable_if {}; template struct hb_enable_if { typedef T type; }; #define hb_enable_if(Cond) typename hb_enable_if<(Cond)>::type* = nullptr