From: Behdad Esfahbod Date: Sat, 11 May 2019 03:20:51 +0000 (-0700) Subject: [meta] Rewrite is_integral / is_floating_point, add is_arithmetic X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e939d88bd72e0db0ebe357649b7a0fa3447c0bf4;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [meta] Rewrite is_integral / is_floating_point, add is_arithmetic --- diff --git a/src/hb-meta.hh b/src/hb-meta.hh index 334a44a..6f141e0 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -221,25 +221,38 @@ struct hb_reference_wrapper }; -template struct hb_is_integral { static constexpr bool value = false;}; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; -template <> struct hb_is_integral { static constexpr bool value = true; }; - -template struct hb_is_floating_point { static constexpr bool value = false;}; -template <> struct hb_is_floating_point { static constexpr bool value = true; }; -template <> struct hb_is_floating_point { static constexpr bool value = true; }; -template <> struct hb_is_floating_point { static constexpr bool value = true; }; - +template +using hb_is_integral = hb_bool_constant< + hb_is_same (hb_decay, char) || + hb_is_same (hb_decay, signed char) || + hb_is_same (hb_decay, unsigned char) || + hb_is_same (hb_decay, signed int) || + hb_is_same (hb_decay, unsigned int) || + hb_is_same (hb_decay, signed short) || + hb_is_same (hb_decay, unsigned short) || + hb_is_same (hb_decay, signed long) || + hb_is_same (hb_decay, unsigned long) || + hb_is_same (hb_decay, signed long long) || + hb_is_same (hb_decay, unsigned long long) || + false +>; #define hb_is_integral(T) hb_is_integral::value +template +using hb_is_floating_point = hb_bool_constant< + hb_is_same (hb_decay, float) || + hb_is_same (hb_decay, double) || + hb_is_same (hb_decay, long double) || + false +>; +#define hb_is_floating_point(T) hb_is_floating_point::value +template +using hb_is_arithmetic = hb_bool_constant< + hb_is_integral (T) || + hb_is_floating_point (T) || + false +>; +#define hb_is_arighmetic(T) hb_is_arighmetic::value + template struct hb_is_signed; template <> struct hb_is_signed { static constexpr bool value = CHAR_MIN < 0; }; template <> struct hb_is_signed { static constexpr bool value = true; };